2009年7月15日星期三

Re: [fw-mvc] howto: capture action output, stream it as pdf

Carlton Gibson-2 wrote:
>
>
>> Sorry, you're dead right. (Except about it being magic :-)
>>
>> If you look at Zend_Layout_Controller_Plugin_Layout::postDispatch()
>> you'll see that the content from the response object is there
>> assigned to the layout instance. This I hadn't told you to do, which
>> is why you don't get the content when you manually render the layout.
>


Yes, this is a working way at least. To contribute back, here is a complete
example (it should be in the docs, because this is not too
trivial…):handshake:

function toPdfAction() {
// I need a different layout
$this->getHelper('layout')->setLayout('pdf-layout');
$this->_helper->layout->disableLayout();

// we need to do renderering ourselves.
$this->getHelper('viewRenderer')->setNoRender();

/* @var $layout Zend_Layout */
$layout = $this->_helper->layout->getLayoutInstance();
$layout->assign('content',
$this->view->render('mycontroller/myaction.tpl'));

$output = $layout->render();

// now we still need to ensure that the rendering is not sent to the
browser
$this->getResponse()->clearBody();

// now do something with $ouput


}

--
View this message in context: http://www.nabble.com/howto%3A-capture-action-output%2C-stream-it-as-pdf-tp24496539p24500594.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: