我的布局显示两次似乎有问题。我想知道这是否是由我的前端控制器插件(见下文)中的某些东西引起的,该插件仅将 Zend Layout 用于特定模块而不是在主应用程序中。任何答案将不胜感激。谢谢
class My_Controller_Plugin_AdoptLayout extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$moduleName = $request->getModuleName();
if ($moduleName == 'some-module') {
if (!Zend_Layout::isEnabled()) {
$view = new Zend_View(array('encoding' => 'UTF-8'));
$view->addScriptPath(ROOT_DIR . '/modules/some-module/views/scripts/');
$view->doctype('XHTML1_STRICT');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
Zend_Layout::startMvc();
$layout = Zend_Layout::getMvcInstance();
$layout->setLayout('default');
$layout->setLayoutPath(APPLICATION_PATH . '/modules/some-module/views/scripts/layouts/');
$layout->setView($view);
}
}
}
}