« Return to Thread: Controller and View Question

Re: Controller and View Question

by Arnaud Limbourg :: Rate this Message:

Reply to Author | View in Thread

Matthew Weier O'Phinney wrote:

> I throw a Zend_View object in the registry, and then access this from my
> controllers and plugins. The benefit of doing this is that the
> controllers can set values in the view that are unused in their
> individual view, but used later in the sitewide template.
>
> Then, I use a dispatchLoopShutdown() plugin to inject any generated
> content into a sitwide template:
>
>
>     class SiteTemplatePlugin extends Zend_Controller_Plugin_Abstract
>     {
>         public function dispatchLoopShutdown()
>         {
>             $response = Zend_Controller_Front:;getInstance()->getResponse();
>             $view = Zend_Registry::get('view');
>             $view->content = $response->getBody();
>             $response->setBody($view->render('site.phtml'));
>         }
>     }

Which poses a problem when you want to send back json (or whatever) and
you don't want a site wide template :)

Arnaud.

 « Return to Thread: Controller and View Question