doze79040
2013-03-18 23:39
浏览 33
已采纳

ZF2视图渲染在另一个视图中

I don't want to add child to the viewModel in action controller:

// action controller
public function indexAction() {
    $result = new ViewModel();
    $result->setTemplate('application/view/another-action');

    $comments = new ViewModel();
    $comments->setTemplate('application/view/child-comments');
    $result->addChild($comments, 'child_comments');

    return $result;
}
...
// View
<div>
<?php echo $this->child_comments ?>
</div>

I want to include view in another view:

<div>
  <?php
  $view = new ViewModel();
  $view->setVariables($this->var);
  $view->setTemplate('page_nav.phtml');
  // here I want to render view 
  ?>
</div>

Is it possible?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题