How to disable Layout and View in Zend Framework Controller

May be you ask why I may need to disable the layout or views. Some times I am not outputting a normal page but XML data so I do not need the Layout. Other situations for example when I do migration for the data and I just need to use the controller to do that the view or the layout is not necessary
to disable the layout and view renderer in specific action use the following methods

$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

If you want to disable them in every action on specific controller you can add them to the init() function as it is run before any thing else in the Controller Class

Leave a Reply