-- Philip G <[EMAIL PROTECTED]> wrote (on Thursday, 20 September 2007, 09:44 AM -0500): > On 9/20/07, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote: > > There's got to be something in your code that's wrong; I do exactly this > > sort of thing in several applications, and it just works. I think to > > diagnose this, I'd need to see: > > > > * The plugin > > * The controller class > > * The view scripts > > > > If you can attach those, or send a link to where to view them, I'll see > > if I can figure out why you're having the issues you are. My inclination > > is that you're not using the same view object in all locations somehow, > > but I won't know for sure unless I see the code. > > > > Sure, here's the code ( long email ):
Thanks -- between this and an answer I just gave someone else, I know what the issue is. Scroll on for a solution: > Controller Plugin: > ( http://www.gpcentre.net/tmp/Plugin.phps ) > -------------------------------------------------------------------------------------- > <?php > > require_once ('Zend/Auth.php'); > require_once ('Zend/Cache.php'); > require_once ('Zend/Registry.php'); > require_once ('Zend/Config/Ini.php'); > require_once ('Zend/Controller/Plugin/Abstract.php'); > require_once ('Zend/Db/Adapter/Pdo/Mysql.php'); > > require_once ('Gpc/User.php'); > > class Gpc_Controller_Plugin extends Zend_Controller_Plugin_Abstract { > > public function routeStartup(Zend_Controller_Request_Abstract $response) { > } > > public function routeShutdown(Zend_Controller_Request_Abstract $response) > { > } First off, in plugins, you don't need to define every method. Just override the methods you wish to utilize, such as the one below: > public function dispatchLoopStartup(Zend_Controller_Request_Abstract > $response) { <snip a little...> > $viewRenderer = > Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); > $view = $viewRenderer->view; At this point, the ViewRenderer hasn't needed to do anything with the view yet, so it actually hasn't even instantiated it! If you'd had on error_reporting, you would have seen some notices and warnings about the view property not existing. Easy solution: before the line above, add this: $viewRenderer->initView(); This will instantiate the view object, allowing you to then access it. -- Matthew Weier O'Phinney PHP Developer | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
