Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include .phtml zend

I have to add a feature to a quite 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.

like image 224
xotix Avatar asked Dec 13 '22 16:12

xotix


1 Answers

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',
    ...
))?>
like image 108
Arnaud Le Blanc Avatar answered Dec 30 '22 09:12

Arnaud Le Blanc