开发者

include .phtml zend

I have to add a feature to a qu开发者_如何学编程ite big app using zend framework.

i have a view. in that view, i have a if and want to include an other .phtml on the same location.

so, at the moment i got something like

if (x = true)
    require_once(the other file);

that works, but isnt in the meaning of zend. i've been told i should use view helpers, more specific, the partial. so, how do i include a phtml file with the partial? i dont get it.


Use the render() view helper like this:

<?=$this->render('the other.phtml')?>

All view variables available in the current .phtml script will be available in the other.phtml too.

If you want to render the other view script with specific view variables, use partial instead:

<?=$this->partial('the other.phtml', array(
    'var'=>'value',
    'var2'=>'value2',
    ...
))?>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜