24-11-2009

Zend Framework Change view script in ZF controller action

To change from the default view script (based on the action's name) and dynamically pick another view script to render you can use the following code:

$this->_helper->viewRenderer->setRender('show-image'); 
 

Now 'show-image.phtml' is rendered

Comments:

5 comments.
Your comment:

»
David Mintz 24/11/2010, 4:07 pm
I am sorry to be gushing and panting like this rather than contributing anything insightful, but: OMG! That is SO COOOL! Thank you!
Daniel Lima 03/01/2011, 8:16 pm
$this->render('foo'); implies the same things =)
Ben 02/08/2011, 11:25 pm
thanks, it really helps :)

Daniel Lima's trick is good too :)
Bo 10/09/2011, 10:07 am
But where should we put these codes?
J 15/09/2011, 9:25 am
in your controller method

 

[x]