我确信这是一个简单的一行,但我似乎找不到它。
如何对特定操作使用不同的布局文件?
更新:这对我很有效,谢谢!
// Within controller
$this->_helper->_layout->setLayout('other-layout') //other-layout.phtml
//Within view script
<?php $this->layout()->setLayout('other-layout'); ?>
发布于 2009-10-24 05:26:05
从控制器内部:
$this->_helper->layout->setLayout('/path/to/your/layout_script');
(通过these docs)
编辑:我需要指出的是,路径是相对于布局目录的(默认情况下是application/layouts/scripts/
)
发布于 2011-09-26 20:09:18
您也可以像这样使用
// Within controller
Zend_Layout::getMvcInstance()->setLayout('layout_name');
//Within view script
<?php $this->layout()->setLayout('layout_name'); ?>
您的布局必须位于/ layout /scripts/文件夹中,否则还需要指定路径。不需要写.phtml,只需要布局的名称
https://stackoverflow.com/questions/1615956
复制相似问题