Explore these results from Bing
- Viewed 4k times3answered Feb 25, 2010 at 17:34
Short answer: maybe you're doing it wrong.
Long answer: Scripts should not be controller dependent. It's 'theoretically' wrong, and cake does not like people who doesn't adhere to the mvc pattern.
Workaround (because sometimes you just need to): You can set in beforeRender a var:
function beforeRender() {parent::beforeRender();$this->set('scripts', array('script1', 'script2' ...));}And in the layout check for $scripts and add them.
Content Under CC-BY-SA license cakephp: can I set $scripts_for_layout from within a controller?
I'd like to set the layout's $scripts_for_layout from within the controller. Is this possible, and if yes how?✓ Short answer: maybe you're doing it wrong. Long answer: Scripts should not be controller dependent. It's 'theoretically' wrong, and cake does not like pe…How to set the content of the $script_for_layout in cakephp?
Class View | CakePHP 2.0
Set $scripts variable for layout in AppController and ...
- People also ask
CakePHP2を美味しく食べたい:$scripts_for_layoutの使い方 ...
Class View | CakePHP 2.4
CakePHPでレイアウトを活用する – helog
Related searches for cakephp $scripts_for_layout