Disabling a Layout or View Renderer in a Zend Framework Controller

Written by James Mansson on October 13, 2013 Categories: Zend Framework 1

By default, in a Zend Framework 1 application, each action handler function in a controller class is assumed to have a corresponding view script. It is also usual to define a standard layout for pages, and apply that layout by default. However, there will be situations where you want to disable the layout, or even not make use of a view script. This could be because you are performing an AJAX action, or because the action simply performs a task before redirecting elsewhere.

To disable the layout, you make the following call in your action handler:

$this->_helper->layout->disableLayout();

To disable the view renderer, so you no longer need to create a view script, you make the following call in your action handler:

$this->_helper->viewRenderer->setNoRender(true);
No Comments on Disabling a Layout or View Renderer in a Zend Framework Controller

Leave a Reply

Your email address will not be published. Required fields are marked *