Enable .phtml zend

I need to add a function to a fairly large application using the zend framework.

I have an idea. in this view, I have an if and want to include another .phtml in the same place.

so at the moment i got something like

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

which works but does not matter zend. I was told that I should use view helpers, more specific, partial. therefore, how to include phtml file with partial? I do not understand.

+4
source share
1 answer

Use a view helper of render() as follows:

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

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

If you want to display a different view of the script with specific view variables, use partial instead:

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

Source: https://habr.com/ru/post/1337344/


All Articles