set/add view from controller action

10,773

If you just want to render some other view script from a controller just:

$this->render('someotherview');

Wich will render someotherview.phtml. from: http://framework.zend.com/manual/en/zend.controller.action.html#zend.controller.action.viewintegration.render

class MyController extends Zend_Controller_Action{
public function fooAction()
{
    // Renders my/foo.phtml
    $this->render();

    // Renders my/bar.phtml
    $this->render('bar');

    // Renders baz.phtml
    $this->render('baz', null, true);

    // Renders my/login.phtml to the 'form' segment of the
    // response object
    $this->render('login', 'form');

    // Renders site.phtml to the 'page' segment of the response
    // object; does not use the 'my/' subirectory
    $this->render('site', 'page', true);
}

public function bazBatAction()
{
    // Renders my/baz-bat.phtml
    $this->render();
}

}

Should get you on the right track!

Also

$this->renderScript('path/to/index.phtml');

Works really well.

Share:
10,773
Max
Author by

Max

Analytics consultant available for hire. More info: https://maxcorbeau.com

Updated on June 04, 2022

Comments

  • Max
    Max almost 2 years

    I'm trying to set a view script to be executed in addition to the currently requested action view script. I want to do this from the controller action itself in a way that this new view script output will be available from the layout $this->layout()->content helper.

    I found the setView() method but don't know how to use it from the controller.

    Thanks a lot.