The ViewRenderer action helper performs two useful functions for us. Firstly, before our action is called,
it creates a Zend_View object and sets it to the action’s $view property allowing us to assign data to the view
within the action. Secondly, after our action finishes it automatically renders the correct view template into the
response object after the controller action has completed. This ensures that our controller’s action functions
can concentrate on the real work and not on the framework “plumbing”.
What is the “correct view template” though? The ViewRenderer looks for a template file named after the
action with a phtml extension within a folder named after the controller and it looks in the view/scripts
directory for this. This means that for the index action within the index controller, it will look for the view
template file view/scripts/index/index.phtml.
As we noted previously, the response’s body is automatically printed by the front controller, so anything
we assign to the body will be displayed in the browser and hence we do not need to echo ourselves.
Zend_View is the View component of the MVC troika and is a fairly simple PHP based template system.
As we have seen, the assign() function is used to pass variables from the main code body to the template which
can then be used within the view template file.
