开发者

Zend frame work multiple view from single action

开发者 https://www.devze.com 2023-01-25 12:31 出处:网络
Can anyone tell me how can i make more then one view through single action. actually I have a controller action fetching data from model but I have to show data in 2 different views (half data in 1st

Can anyone tell me how can i make more then one view through single action.

actually I have a controller action fetching data from model but I have to show data in 2 different views (half data in 1st and rest in 2nd)

I know it is possible.

Can any one开发者_高级运维 explain how it will be implemented.


I'm not entirely sure whether you mean having two different views depending on a condition or two views at the same time.

From the action you can use:

$this->renderScript( 'views/page.phtml' );

and you can use multiple renderScripts and they will stack up and render in the order that they are called. Or you can have a condition separating them.

if($blah)
{
    $this->renderScript( 'views/page.phtml' );
    return;
}
else
{
    $this->renderScript( 'views/page.phtml' );
    return;
}

Is this the sort of thing you mean?


Just use the render method of the controller action to display the view you want.

Refer to Rendering Views in the Zend reference manual for more information (you could also use Named Segments if needed/applicable).

0

精彩评论

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