I came across the case where depending on the execution path I may need to invoke an inclusion of .js file from controller. Is there a nice way of doing it? (besides setting some view variable with actual .js include code)?
A:
Sure, you could do like @Bill Karwin described.
But if you would like to do it really nicely, you need template inheritance - like it is implemented in Django framework for Python for instance. There are some extensions for Zend Framework as well, take a look at Calypso.
martinsb
2008-11-16 09:22:45
+2
A:
See the view helper headScript(). I'm just writing this off the top of my head but I think it works like this:
From within a view file: $this->headScript()->appendFile('filename.js');
From within a controller: $this->view->headScript()->appendFile('filename.js');
And then somewhere in your layout you need to echo out your headScript object:
<?=$this->headScript();?>
smack0007
2008-11-16 11:47:56