How to disable layout and view in Zend Framework

Programmers need to disable layout and view some times when they need to export some data in the form of CSV or tab delimited text file. When this need arises you can add two lines to your controller action which will disable the layout and view code from your web page. Add the following code at the start of your controller action.

// This line disables the layout
$this->_helper->layout->disableLayout();

// This line disables the actual view
$this->_helper->viewRenderer->setNeverRender();
Please follow and like us:
error

Be the first to comment

Leave a Reply

Your email address will not be published.