Skip to content
Advertisement

ZendFramework – How to add ->HeadScript() from Controllers?

I have a case where i need to add the Javascript from controller to the Layout where it has already HeadScript();

How to do that from controller?

e.g: $this->view->HeadScript()->appendScript();

This is controller: Both does not apply.

JavaScript

This is the view file: index.phtml

JavaScript

If i uncomment in view it works but not in Controller. I want to apply this from controller how now?

Advertisement

Answer

I got this to work from the preDispatch method in a controller, remember you have to pass layout changes before headers are passed.

JavaScript

you still have to have the headScript placeholder in your layout.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement