I have a controller that opens a container view. The container then hands the building of the page to several views including the “html_meta” view and the “top_bar”, “side_bar”, “content” views. However, the content contains several different views too many of which can be considered gadgets, or small contained html divs with different data, script actions.
Question:
If I want the HTML header/meta to include only the scripts that that the specific gadget views need, is there a way for the gadget views to send the necessary script components back up the line to the container view so that it can process them and add the scripts to the html head?
- If it helps I can include the code, but for now, I think it gets messy here. However, if you need code to visualize it, no problem. Thanks!
As an example my controller calls the main
containerbut I have to pass it my content which is from another view as suchThen
layout/container.phpcontains severalIt’s possible but it’s not the subviews “informing” the “html_meta” to include the javascripts that it needs because your views are rendered from the main container down to the sub views.
What you can do is create a helper for your external java scripts. I’m thinking of having a javascript group for each of your widgets such as
Then in your controller function you also pass those scripts, or possible your constructor.
So now,
$custom_jsis accessible in yourlayout/container.php. But it’s not yet inlayout/html_meta. So I’ll assign this to an array, and pass it again tolayout/html_meta.Then in your
layout/html_meta, you can now use$custom_jsto insert additional javascripts aside from your common scripts.