Skip to content Skip to sidebar Skip to footer

How To Attach Css And Javascript Files In Zf2 Controller?

i attach some stylesheets in zend controller but blank page shown,how i include stylesheets and javascript files in zend controller?here is my code: public function showAction()

Solution 1:

The 'blank page' just means an error is being generated but you have display_errors turned off. Check your web server error log to see what the actual problem is (this will help you debug future issues as well).

From looking at your code, I'd guess the problem is with the calls to $this->viewHelperManager, as there is no such thing (unless you've set that elsewhere in your controller).

You probably want:

$this->getServiceLocator()->get('viewhelpermanager')->get('headLink')->appendStylesheet('/css/style.css');

although if you need that many view helper calls it might be worth passing the headLink helper in as a dependency.

Post a Comment for "How To Attach Css And Javascript Files In Zf2 Controller?"