Home - Web Developer Blog

Zend Framework

Zend Disable View Renderer and Layout

When an action does not require a layout or view script, it is possible in Zend to disable both resources individually.

The code to disable the view renderer and layout can be found below

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

This code can be placed within two different locations in the controller to disable the view and layout scripts. If you want to disable them for a single action then place the code anywhere in the function for that action. If you want to disable the view and layout scripts for all actions in a controller then you can place the code in either the pre_dispatch() or init() functions for that controller like below

    public function init()
    {
       $this->_helper->layout()->disableLayout();
       $this->_helper->viewRenderer->setNoRender(true);
    }

Net Tuts Code Canyon Get Noticed - $7.99 .Com or .CO from GoDaddy.com!