2009年6月19日星期五

Re: [fw-mvc] How to render different actions?

In the reference guide, "Chapter 12. Zend_Controller", "12.8 Action Helpers", "Example 12.3. Adding a Task Using a Request Object"
(http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.actionstack)

I have not understood very well what is the utility of that helper, but isn't it what I need?
If I do that:

public function reportAction(){        $myReportContent = '';     $myReportPages = array(        array('aModule', 'aController', 'anAction'),      //page 1 of my report, the view related to the action is a Latex template        array('aModule', 'aController', 'anOtherAction')    //page 2 of my report     );          $request = clone $this->getRequest();     $request->setActionName('anAction') 		->setModuleName('aModule') 		->setControllerName('aController') 		->setParams(array('bar' => 'baz'));       $myReportContent  .= $this->_helper->actionStack($request);         ...        file_put_content($myReportContent, 'myfile.tex');     ... } 
and in aModule/aController/anAction
I will return $this->render();

Am I in the right way ???

Thanks a lot

Bertrand

MarkDNA a écrit :
 Bertrand Chevrier wrote:   
Hi,  I would like to use Zend-Mvc to create a dynamic LaTeX documen. My problem is: how can I call some other module/controller/actions into an action, and get the result into a variable. Each one of the other  module/controller/actions will represent a page of my LateX report and the main action will be called as a normal action (by the url). For example in my controller  public function reportAction(){      $myReportPages = array(        array('aModule', 'aController', 'anAction'),      //page 1 of my report, the view related to the action is a Latex template        array('aModule', 'aController', 'anOtherAction')    //page 2 of my report     );     // create my report and get the results into a variable    file_put_content($myReportContent, 'myfile.tex');    ....  } This case applies to my report, but this is a more general question: how to call actions manually? I hope I'm clear, and I'm sorry for the English mistakes. thanks, Bertrand Chevrier      
 I'll give a try at this. Undoubtedly one of the gurus will come and clean up my mistakes, but this should point in the right direction.  $page1 = $this->_forward('anAction', 'aController', 'aModule'); $page2 = $this->_forward('anotherAction', 'aController', 'aModule');  Having a return value in those actions should keep them from trying to render, but you may need to add: $this->_helper->viewRenderer->setNoRender(true); to keep anAction and anotherAction from rendering.  I have not tried this code, it's just a best guess.   -Mark    ----- Mark Garrett DNA Arkadelphia, AR (Telecommuting to: Rogue River, OR)   

没有评论: