-- David Mintz <[email protected]> wrote (on Friday, 23 January 2009, 05:06 PM -0500): > > > On Fri, Jan 23, 2009 at 4:36 PM, Matthew Weier O'Phinney <[email protected]> > wrote: > > -- 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); > > > > Same story. e.g., I stick this stdClass $user object in the view in my > bootstrap, and can dump it in the view, but the helper doesn't see it. How do > people deal with this? It's got to be a common scenario. I suppose I could > pass > whatever to the helper as args to the helper call. > > Would it make a difference if I set these view vars in a plugin? Hmm I think > I'll try and see for myself...
Shouldn't make a difference. The other possibility is that it's an issue in your helper. Are you extending Zend_View_Helper_Abstract? That class provides a setView() implementation, which will ensure that $this->view is available in your helper. -- Matthew Weier O'Phinney Software Architect | [email protected] Zend Framework | http://framework.zend.com/
