How to switch layout files in Zend Framework?

I am sure this is a simple single line, but I can not find it.

How can I use a different layout file for a specific action?

Update: This worked for me, thanks!

// Within controller $this->_helper->_layout->setLayout('other-layout') //other-layout.phtml //Within view script <?php $this->layout()->setLayout('other-layout'); ?> 
+60
php layout zend-framework zend-view zend-layout
Oct 23 '09 at 21:20
source share
2 answers

From inside the controller:

 $this->_helper->layout->setLayout('/path/to/your/layout_script'); 

(through these documents )

EDIT: I should mention that the path refers to any layout directory (by default it is application/layouts/scripts/ )

+62
Oct 23 '09 at 21:26
source share

You can also use this.

 // Within controller Zend_Layout::getMvcInstance()->setLayout('layout_name'); //Within view script <?php $this->layout()->setLayout('layout_name'); ?> 

Your layout should be in the / layouts / scripts / folder, otherwise you also need to specify a path. No need to write .phtml, just a layout name

+13
Sep 26 '11 at 12:09
source share



All Articles