如果我的应用程序中有 2 个布局,如何将我的默认布局更改为某些控制器或操作的其他布局?
问问题
1828 次
3 回答
7
robertbasic 的回答是正确的。您还可以在控制器操作中执行以下操作:
$this->_helper->layout->setLayout('otherlayout');
于 2010-02-03T22:34:23.403 回答
2
干得好:
$layout = Zend_Layout::getMvcInstance();
$layout->setLayout('otherlayout');
第二个布局的名称在哪里otherlayout
(布局文件夹中的 otherlayout.phtml)。
于 2010-02-03T21:15:36.400 回答
1
在我看来,最好使用
$layout = Zend_Layout::getMvcInstance();
$layout->setLayout('otherlayout');
在您看来,而不是使用
$this->_helper->layout->setLayout('otherlayout');
从控制器。
后一种方法有一个错误。我有一次使用的经验
$this->_helper->layout->setLayout('otherlayout');
并且新布局显示在旧布局内。我用了
$layout = Zend_Layout::getMvcInstance();
$layout->setLayout('otherlayout');
然后它起作用了
于 2011-02-02T02:48:55.740 回答