How to set multiple layout in Zend FrameWork

By | January 27, 2014

During developing an application we need to set the multiple layout for a particular controller, action, view.

Set layout for a particular controller or action:

Within Controller/action

1
2
3
4
5
<?php   
(a) Zend_Layout::getMvcInstance()->setLayout('layout_name');
            
(b) $this->_helper->layout()->setLayout('layout-user');
?>

Within View

1
<?php $this->layout()->setLayout('layout_name'); ?>

Disable layout for a particular controller or action:

Within controller, action

1
2
3
4
<?php
$this->_helper->layout()->disableLayout(); 
$this->_helper->viewRenderer->setNoRender(true);
?>

Leave a Reply