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 ): 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) { } public function dispatchLoopStartup(Zend_Controller_Request_Abstract $response) { // Load config $config = new Zend_Config_Ini(CONFIG, 'production'); $db = new Zend_Db_Adapter_Pdo_Mysql( array( 'host' => (string)$config->database->host, 'username' => (string)$config->database->user, 'password' => (string)$config->database->password, 'dbname' => (string)$config->database->dbname, )); Zend_Registry::set('config', $config); Zend_Registry::set('db', $db); $this->user = Gpc_User::factory($config->forum->software); $this->user->checkForCookie(); // Checks for the user data cookie and moves forward $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $view = $viewRenderer->view; if ( Zend_Auth::getInstance()->hasIdentity() ) { $identity = Zend_Auth::getInstance()->getIdentity(); Zend_Registry::set('identity', $identity); $view->user = $this->user; $view->testVar = "This is a test"; print "logged in"; $view->login = "Yes"; } else { print "not logged in"; $view->login = "No"; } } public function preDispatch(Zend_Controller_Request_Abstract $response) { } public function postDispatch(Zend_Controller_Request_Abstract $response) { } public function dispatchLoopShutdown() { } } -------------------------------------------------------------------------------- The IndexController: ( http://www.gpcentre.net/tmp/IndexController.phps ) ---------------------------------------------------------------------------------- <?php require_once ('Zend/Controller/Action.php'); class IndexController extends Zend_Controller_Action { public function indexAction() { $this->view->test2 = "run!"; } } ------------------------------------------------------------------------------ The View file (under views/scripts/index/index.phtml): ( http://www.gpcentre.net/tmp/index.phps ) --------------------------------------------------------------------------- File: index/index.phtml <? print_r($this->user) ?> <? print_r($this->login) ?> <? print_r($this->testVar) ?> <? print_r($this->test2) ?> ------------------------------------------------------------------------- I successfully get the prints on the page, but fail to get anything else. I'd give you the link where it's currently running, but it's behind a passwd protected wall at the moment due to some other software I have installed there for testing (TOS requires I passwd protect it if I'm testing not purchasing). -- Philip [EMAIL PROTECTED] http://www.gpcentre.net/
