我正在尝试使用zf2
创建嵌套视图模型。zf2:嵌套查看模型问题
我使用标准zf2
框架应用程序。
在我IndexController
:
public function indexAction()
{
$view = new ViewModel();
$view->setTemplate('application/index/index.phtml');
$aboutView = new ViewModel();
$aboutView->setTemplate('application/index/about.phtml'); //standard html
$view->addChild($aboutView, 'about');
return $view;
}
在我layout.phtml
,我添加以下代码:
HTML代码:
echo $this->content
HTML代码:
echo $this->about;
嵌套视图未显示在结果中。当var_dump($this->about)
,我越来越NULL.
任何想法我做错了什么?
你试图呈现'about' layout.phtml'里面?但你将它附加到'index.phtml'。 – claustrofob