簡體   English   中英

如何在Zend 1.11中呈現2個不同控制器的不同動作的視圖

[英]How to render 2 views of different actions of different controllers in Zend 1.11

我有2個控制器。

  1. 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'); } 
  2. 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM