我试图在我的布局中添加另一个模块的视图,所以我这样做:
$layoutTestdrive = new ViewModel();
$layoutTestdrive->setTemplate('testdrive6');
$view = new ViewModel();
$view->addChild($layoutTestdrive);
return $view;在我的module.config.php中,我这样做了:
'Zend\View\Resolver\TemplateMapResolver' => array(
'parameters' => array(
'map' => array(
'testdrive6' => __DIR__ . '/../../Testdrive/view/layout/testdrive6.phtml'
),
),
),这是正确的吗?
发布于 2012-10-11 00:04:12
您好,我认为您需要先使用forward
public function commentAction(){
$list = $this->forward()->dispatch('comment_controrller', array('action' => 'list'));
$add = $this->forward()->dispatch('comment_controrller', array('action' => 'add'));
$view = new ViewModel();
$view->addChild($list, 'list');
$view->addChild($add, 'add');
return $view;
}我希望这能有所帮助。
或者,如果您只想更改模板,请参阅Different layout file for different controller
https://stackoverflow.com/questions/12714739
复制相似问题