Prev | Current Page 42 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

For Hello World, our indexAction() function just needs to assign a variable to the view
property which is provided for us by an Action Helper called ViewRenderer.
NOTE
An Action Helper is a class that plugs into the controller to provide services specific to actions.
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.


Pages:
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
ABBA 2 1 DMOZ biznes ubrania opony samochodowe