Zend Framework: partial() and render()

partial() will render a view script, and render() will render a view script. So… which one do I have to use?

All depends on the variable scope.


The render() function will render the given view script within the variable scope of the script is was called from.



partial() will also render the given view script, but you can define a special variable scope: you can pass all requested parameters in an array.

$this->partial('script.phtml', array('var1' => 'value 1', 'var2' => 'value 2'));

This can be very useful to use a view script in a loop.

3 thoughts on “Zend Framework: partial() and render()”

Comments are closed.