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);
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?
Gratefully,
--
David Mintz
http://davidmintz.org/
The subtle source is clear and bright
The tributary streams flow through the darkness