How to switch layout files in Zend Framework? How to switch layout files in Zend Framework? php php

How to switch layout files in Zend Framework?


From inside a Controller:

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

(via these docs)

EDIT: I should mention that the path is relative to whatever your layout directory is (by default, it's application/layouts/scripts/)


You can also use like this

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

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