从您的Bootstrap.php文件中,您可以执行以下操作:
protected function _initLayoutName()
{
// use sitelayout.phtml as the main layout file
Zend_Layout::getMvcInstance()->setLayout('sitelayout');
}
如果要为不同的模块使用不同的布局,则需要在Bootstrap中注册插件并使插件包含以下代码:
class Application_Plugin_LayoutSwitcher extends Zend_Controller_Plugin_Abstract
{
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
$module = $request->getModuleName(); // get the name of the current module
if ('admin' == $module) {
// set the layout to admin.phtml if we are in admin module
Zend_Layout::getMvcInstance()->setLayout('admin');
} else if ('somethingelse' == $module) {
Zend_Layout::getMvcInstance()->setLayout('somethingelse');
}
}
}
在application.ini中,您可以执行此操作来设置布局脚本:
resources.layout.layout = "layoutname"
但是,这不适用于每个布局.如果需要根据模块更改布局,则必须使用插件,但可以使用application.ini中的设置来设置默认布局名称.