开发者

set/add view from controller action

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 outp开发者_如何学Gout 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜