Zend Framework Controller and View Interaction
Tuesday, October 6, 2009
As mentioned previously, the framework normally tries to find and execute a view script after exiting the action method in the controller class; to stop it from doing this, you need to add the following line to the method:
$this->_helper->viewRenderer->setNoRender(true);
The basic mechanism for passing data from the controller to the view script is via the Zend_View object. This is referenced by $this->view in the controller class, but simply by $this in the view script, since that is executing within the context of the Zend_View object.
For instance, you might set an error message in you action handler like this:
$this->view->error = "Unable to connect to database.";
Then retrieve and display the error message like this:
echo '<p class="error">' . $this->error . '</p>';
In the next post we shall look at view helpers, then we shall move on to layouts.

Practical Web 2.0 Applications with PHP (Expert's Voice) by Quentin Zervaas
Beginning Databases with PostreSQL: From Expert to Professional 2nd Edition: From Novice to Professional by Neil Matthew, Richard Stones