-- David Mintz <[email protected]> wrote
(on Friday, 23 January 2009, 04:14 PM -0500):
> I have view variables that I want to be set in every view instance -- things
> like paths to public resources. So I have been doing something stolen from an
> example somewhere a long while ago:
> 
> $view = new Zend_View;
> $view->web_root = Zend_Registry::get('siteConfig')->paths->web_root;
> if (Zend_Auth::getInstance()->hasIdentity()) {
>     $view->user = Zend_Auth::getInstance()->getIdentity();
> }
> // etc
> $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
> $viewRenderer->setView($view);
> Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

Try changing the above three lines to this, and see if it makes any
difference:

    $viewRenderer = 
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')
    $viewRenderer->setView($view);


> These view vars are referenced in the layout and/or in the individual views,
> and it's all good, except in the view helpers. Here,  $this->view can see the
> variables that are set in the view instance by the controller action, but not
> the ones that are set above in the bootstrap.
> 
> So -- what am I doing wrong, what's the best practice for setting app-wide 
> view
> variables?

-- 
Matthew Weier O'Phinney
Software Architect       | [email protected]
Zend Framework           | http://framework.zend.com/

Reply via email to