[英]How to render 2 views of different actions of different controllers in Zend 1.11
我有2个控制器。
CategoryController
public function readAction() { $id = $this->_request->getParam('id'); $categoryModel = new Model_Category(); if(!$categoryModel) { throw new \\Exception(__METHOD__.', could not create category model'); } $category = $categoryModel->getCategory($id); $parent = $category->findParentRow(new Model_Category()); if(!$parent) { $this->view->parent = 'no parent'; } else { $this->view->parent = $parent->name; } // I need to pass category object to read.phtml of controller category // so that each attributes of the category could be displayed. $this->view->category = $category; // Below the category section, I also need to list all // the business entities which are the child rows of that category. // So I forward to controller business, action list. // Normally I use list.phtml in controller business to do that. $this->_forward('list', 'business'); }
BusinessController
但是在我调用_forward之后,read.phtml没有显示出来,我只能看到控制器业务的list.phtml。 我的问题是,如果我想同时调用控制器类别的read.phtml和控制器业务的list.phtml,该怎么办?
转发前呈现当前操作:
public function readAction()
{
// ...
$this->render();
$this->_forward('list', 'business');
}
在您的read.phtml视图中,您可以使用:
回声$ this-> render('business / list.phtml');
显示其他视图。
您可以使用$viewRenderer->setResponseSegment('someOtherThanContent')
并通过使用
$this->layout()->someOtherThanContent;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.