-- jlevy <[EMAIL PROTECTED]> wrote
(on Friday, 15 June 2007, 09:48 AM -0700):
> Odd, that my view is 'null'.
> 
> $view =
> Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view;
> 
> $view->assign('foo', 'bar');
> 
> yields a null view object. 

Probably as you're retrieving it prior to the view being instantiated
(it's instantiated the first time the first controller called is
initialized). You can always do this:

  $viewRenderer = 
Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
  $viewRenderer->initView();
  $view = $viewRenderer->view;
  $view->assign('foo', 'bar');
    
This will only be necessary if calling via routeStartup|Shutdown() or
preDispatch().


> Andries Seutens wrote:
> > 
> > jlevy schreef:
> >> I'd like to set a var, or series of vars and make available to my view
> >> from a
> >> plugin.
> >> 
> >> In a project I'd done w/ZF .8, I had the view set in my registry, and it
> >> was
> >> as simply matter of fetching the view out of the reg and setting a
> >> var/vars.
> >> The view script would then see the vars easily.
> >> 
> >> In a new project I'm working on, I've avoided the use of the registry,
> >> and
> >> am having difficulty determining where the view object is, how to get it,
> >> and consequently, how to set some vars into it.
> >> 
> >> Does the view object even exist yet (my plugin fires at routeStartup)?
> >> 
> >> Is the view available from a plugin?
> >> 
> >> Thanks, and I appreciate the help. I'm struggling just a bit trying to
> >> adapt
> >> to RC2, so forgive any ridiculous questions or assumptions I might make.
> > 
> > Hi,
> > 
> > You could do:
> > 
> > $view = 
> > Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view;
> > 
> > $view->assign('foo', 'bar');
> > 
> > Best,
> > 
> > Andries Seutens
> > http://andries.systray.be
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Accessing-View-from-a-Plugin--tf3928197s16154.html#a11143569
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to