Sunday, April 3, 2011

Disable Zend_Layout and Zend_View

Disabling Zend Layout

$layout = Zend_Layout::getMvcInstance();
if ($layout) {
    $layout->disableLayout();
}

Prevent Zend_View From Rendering in the Current Action / State

$this->_helper->viewRenderer->setNoRender();
Note: Put the above code post-bootstrap of the front-controller. Meaning you should put them through a Controller Plugin or [your_zend_controller]::init() or [your_zend_controller]::preDispatch() methods. This is because at the bootstrap level, the layout and views objects are still out of scope or not yet instantiated. They become available after the routerShutdown() method of the front controller.

 What do you use them for?
1) They become very important when you want to use Zend Framework for Web Services or REST API development.
2) They are very useful for widget programming or use of HTML components to construct your page with a high degree of decoupling / encapsulation.
3) They can be used for simple ZF CLI implementation
  • Related Links Widget for Blogspot

No comments: