-- drj201 <[EMAIL PROTECTED]> wrote
(on Saturday, 25 October 2008, 06:48 AM -0700):
>
> Can someone please confirm if this is the expected behaviour please or simply
> if I am doing something wrong? Thanks. :)
If you look at how Zend_Layout registers its plugin, you'll see that it
uses a particular plugin index to ensure that that it plays well with
the error handler:
$front->registerPlugin(new $pluginClass($this), 99);
Register your custom plugin with that same index, and you should be
fine.
> drj201 wrote:
> >
> > I have a front controller plugin to override the default behavior of
> > Zend_Layout via Zend_Layout::startMvc like so:
> >
> > class MyApp_Layout_Controller_Plugin_Layout extends
> > Zend_Layout_Controller_Plugin_Layout
> > {
> >
> > public function preDispatch(Zend_Controller_Request_Abstract $request)
> > {
> >
> > switch ($request->getModuleName())
> > {
> > case 'admin':
> > $this->_moduleChange('admin');
> > break;
> > case 'module2':
> > $this->_moduleChange('module2');
> > break;
> > // Use default Layout
> > }
> > }
> >
> > protected function _moduleChange($moduleName)
> > {
> >
> >
> > $this->getLayout()->setLayoutPath(dirname(dirname($this->getLayout()->getLayoutPath()))
> > . DIRECTORY_SEPARATOR . 'modules/' . $moduleName . '/views/layouts');
> > $this->getLayout()->setLayout($moduleName);
> >
> > return;
> > }
> >
> > }
> >
> > Im experiencing unexpected behaviour with the above and the use of
> > modules. The above works fine for calls to http://my-app/controller-name
> > (controllers in the default directory) and works fine for modules (and
> > their controllers) that exist i.e. http://my-app/module-name or
> > http://my-app/module-name/controller-name.
> >
> > When navigating to http://my-app/does-not-exist or
> > http://my-app/module-name/does-not-exist I am getting the wrong path
> > returned in the setLayoutPath. It seems that when the Error Controller is
> > called the Zend_Layout::startMvc plugin is called again (calling the
> > plugin on preDispatch twice builds an incorrect path to use for the layout
> > script)!
> >
> > Investigating further by simply echoing some text in the preDispatch
> > function of the plugin (crude test I know) it appears that when navigating
> > to a path that does not exist (i.e. no controller) the text is echoed
> > twice! Is this default behaviour i.e. when ErrorController is called so is
> > the plugin?
> >
> > Thanks in advance for any insight! However small!
> >
> > Regards,
> >
> > Dave
> >
>
> --
> View this message in context:
> http://www.nabble.com/Default-behavior-of-Zend_Layout%3A%3AstartMvc-and-plugin-use--tp20031977p20164288.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/