So I have a parent layout called "font.php" which is located in "protected>views>layouts". What I would love to be able to do is to add PHP code at the top of this file so that all subsequent child views can access it.
I've tried declaring globals but they do not work, I've also tried define() and that does not work. Is there a simple way to achieve this.
Thanks.
Inside your both layout and view you have $this, which is instance of current controller. The simpliest way is to add some properties to controller and access them from layout and child views.
Regarding a global variable in your layout file, the short answer is no. Your layout file wraps the view file after the fact, it isn't called before hand.
Related
I have multiple buttons and form inputs in one page. All these buttons and form inputs need to be disabled or enabled depending on a condition.
I know that it is possible to use the disabled keyword inside a tag to disable a specific input or button. Also, I can just add the code
:disabled="true"
to disable the inputs depending of the boolean value of a variable.
However, this solution is not acceptable for me, since I will have to add this line of code to every inputs on my page (I may create new pages in the future, containing as many inputs).
I would like to know if there's a way that allows me to simply disable the parent container of all the inputs so that the children item (the inputs) are disabled.
If you inspect the Vue instance itself of the VM when running your code you can have something like this when you console.log(this),
It will give you output similar to this if you use the correct scope:
{
$attrs
$options
.......
$el
}
Inside $el there's object properties for accessing firsElementChild, previousElementChild, previousElementSibling, etc. There's a lot of HTML related properties, however, accessing HTML element this way can get messy pretty fast. I think that your best solution is the one you already mentioned or changing the CSS class dynamically.
If you use v-if to conditional render on a parent you can achieve pretty similar functionality too.
See: Conditional rendering
I am new to JavaFX and I want to know if there is way to place one fxml file as in child.fxml inside another say parent.fxml.
Why do i need this ?
Idea is, i want create independent screens(small one) and write a parent fxml where we can add these child fxml to create a desired GUI, instead of one fxml where i dump all the controls.
If it's possible, please help with some dummy code or links. I have tried looking around for a while but did not get anything useful.
Thanks in advance for any help.
If I understand correctly you want to use "fx:include" tag. Please refer the fxml reference
I have a standard Master-Detail Interface and I'm using Coredata and cocoa bindings.
The Master list uses a NSOutlineView and a NSTreeController, these items remain static but different details views are swapped in and out.
So, how do I set the content of the array controllers in the different detail views to correspond to the selection in the outlineview in the Masterview?
This is straight forward if all the array/treecontrollers are in the same .xib file. initially, I tried creating an Outlet from of the Treecontroller and passing this to the orther views as they are created, but I don't think this is correct.
Any suggestions?
You can use an array controller or a tree controller for as many views as you like. In your specific example, I would make the masterview owner of the tree-controller (unless you have a compelling reason to go yet another level up). Then each detail view that gets swapped-in would also have view controllers. That controller would have an assignable "tree-controller" property that would get set before its view is loaded to the value of the "master" tree-controller. Within the Nib files you can use bindings (to the tree-controller of files-owner) as you normally would.
Is this possible to apply new style to already created DialogViewController? In one of my views I need to clear root and change from grouped to plain view.
Just setting style to new one doesn't do anything, so I'm not sure if I need to call some refresh method or this is not possible at all.
Found out looking at Monotouch.Dialog code that you need to call TableView.LoadView for this to happen.
Is it possible to create a layout file inside of a module ? How ?
For what:
I want to add a some kind of statistics hit counter for products, and I don't want to override the products class, as that is already done by some module I'm using. Thus I thought it would be best to have a custom module with a block that would be called by a layout statement.
Of course I could easily edit my private local.xml or make changes to another layout-xml in the layout folder of my theme, but I want this feature to be available in all themes (independent of any selected theme).
Some constraints:
All code in one single module
... so that it is theme independent
... so that the module can be shared with others without them having to change anything (like theme files), so that the install/load of my module would be enough
I would also accept different approaches for my statistics hit counter loading (using the same constraints)
Yes it is possible. Just create your layout xml file in the following path: /design/frontend/default/default/layout/yourlayout.xml(or whatever your theme name is), and add a proper statement in your modules etc/config.xml:
<config>
<frontend>
<layout>
<updates>
<yourmoduleshortname>
<file>yourlayout.xml</file>
<yourmoduleshortname>
</updates>
</layout>
</frontend>
</config>
This sample is for frontend user, but adminhtml layouts can be updated in a similar manner. If something doesn't work, be sure to check if your layout is in the proper theme/package directory.
Edit:
Second approach:
You can use a controller of your own, which will extend the core functionality (one of the catalog controllers) - just rewrite it (or just product view action). Inside its action method add something like this:
$thiss->getLayout()->createBlock('namespacename/block','layout-block-name',
array('template' => 'relativepathtotemplate.phtml'));
$this->getLayout()->getBlock('content')->append($block);
run-original-parent-code();
Third approach:
Similar to the previous one, but you can use some event observer, and try Mage::getSingleton('core/layout'), and inject your block there. Not in all events the layout will be already available (try the post_dispatch family).
I don't really recommend the second and third approach, because if someone else wants to find where this 'magic' block comes from, it will most surely look int app/design/(...) directory. Finding it in your controller or model, may be very tricky...
If you don't want to display your statistic counter, you can also use events (like post_dispatch) to count the controller dispatches. Just create an observer attached to it, and store your data in the DB.