I use a the layouts directory inside every module. If you have for example a different skin for each module you will need to have sub directories inside the layouts directory in each module as well as the views directory and the public directory.
On Fri, May 8, 2009 at 2:58 PM, Sergio Rinaudo <[email protected]>wrote: > Thank you to everyone, especially to Mon that posted this ultra clear > example. > I have just one more question about this, is better to keep a single layout > directory outside of the module > and the change the layout name, like I did: > > class Admin_Bootstrap extends Zend_Application_Module_Bootstrap > { > public function lazyInit() > { > $appBootstrap = $this->getApplication(); > $appBootstrap->bootstrap('layout'); > $layout = $appBootstrap->getResource('layout'); > $layout->setLayout('admin'); // same directory, APPLICATION_PATH > "/layouts" I changed only the layout name > } > } > > > or having a layout directory inside each module? > > > > ------------------------------ > From: [email protected] > Date: Fri, 8 May 2009 10:17:10 +0800 > > To: [email protected] > Subject: Re: [fw-general] ZF1.8 Switching layouts between modules. > > What you basically need is to defer the setting of layout until > routeShutdown. This can be done with a controller plugin. Matthew's > suggestion [ > http://framework.zend.com/issues/browse/ZF-6568?focusedCommentId=30741#action_30741] > is to have your module bootstrap register a plugin which implements > routeShutdown() or dispatchLoopStartup(). The plugin method checks the > current module, then do stuff if it matches with the calling bootstrap > module. > > Personally, I don't like this method because it could lead to lots of > unused plugins. I prefer to have only one plugin that pulls the current > module from the request, pulls its bootstrap from the modules resource and > executes a specific method. > > class Mz_Plugin_ModuleLazyInit extends Zend_Controller_Plugin_Abstract > { > protected $_bootstraps; > > public function __construct($bootstraps) > { > $this->_bootstraps = $bootstraps; > } > > public function routeShutdown(Zend_Controller_Request_Abstract > $request) > { > $module = $request->getModuleName(); > if (isset($this->_bootstraps[$module])) { > $bootstrap = $this->_bootstraps[$module]; > if (method_exists($bootstrap, 'lazyInit')) { > $bootstrap->lazyInit(); > } > } > } > } > > // application bootstrap > protected function _initPlugins() > { > if ($this->hasPluginResource('modules')) { > $this->bootstrap('modules'); > $this->bootstrap('frontController'); > $bootstraps = $this->getResource('modules'); > $front = $this->getResource('frontController'); > > $plugin = new Mz_Plugin_ModuleLazyInit($bootstraps); > $front->registerPlugin($plugin); > } > } > > // module bootstrap > public function lazyInit() > { > $appBootstrap = $this->getApplication(); > $appBootstrap->bootstrap('layout'); > $layout = $appBootstrap->getResource('layout'); > $layout->setLayoutPath(dirname(__FILE__) . '/layouts'); > } > > > > -- Mon > > > On Fri, May 8, 2009 at 8:25 AM, Karl <[email protected]> wrote: > > I still have the same problem and have not been able to get different > layouts to work when using modules. Can this actually be achieved or are we > all trying something that has not been implemented ? > > Regards, > Karl > > ------------------------------ > *From:* Sergio Rinaudo [mailto:[email protected]] > *Sent:* 07 May 2009 10:50 PM > *To:* [email protected]; [email protected] > *Subject:* RE: [fw-general] ZF1.8 Switching layouts between modules. > > Hi matthew, > I added the line you said, and the layout is switched, but unfortunatelly > for all modules, so also the default module is rendered with the admin > layout. Any advice? > > Sergio Rinaudo > > > > > > Date: Thu, 7 May 2009 16:18:44 -0400 > > From: [email protected] > > To: [email protected] > > Subject: Re: [fw-general] ZF1.8 Switching layouts between modules. > > > > -- Sergio Rinaudo <[email protected]> wrote > > (on Thursday, 07 May 2009, 08:54 PM +0200): > > > I've almost completed to implement all my past work in the new > > > Zend_Application, I still have the problem on how switch layouts > between > > > modules. I noticed here you can specify this in the configuration ini > file: > > > > > > > http://framework.zend.com/manual/en/zend.application.available-resources.html# > > > zend.application.available-resources.modules.configExample > > > > > > but if I add this line on my ini > > > > > > admin.resources.layout.layout = "admin" > > > > > > I get the error > > > > > > Fatal error: Uncaught exception 'Zend_Application_Bootstrap_Exception' > with > > > message 'Resource matching "frontcontroller" not found' in > > > > I know what's happening here. > > > > The layout resource has this: > > > > $this->getBootstrap()->bootstrap('FrontController'); > > > > The problem is that your _module_ bootstrap doesn't have the resources > > that the _application_ bootstrap had -- and so it's finding no matching > > resource to bootstrap. > > > > One workaround is to add this to your configuration: > > > > admin.resources.frontController[] = > > > > This will grab and return the front controller singleton, which should > > work for these purposes. > > > > -- > > Matthew Weier O'Phinney > > Project Lead | [email protected] > > Zend Framework | http://framework.zend.com/ > > ------------------------------ > Cerchi i tuoi spazi? Hotmail va oltre i 5GB. Scopri perché! > > > > ------------------------------ > Chiamate gratis da PC a PC? Provale da > Messenger!<http://messenger.it/videoconversazioni.aspx> > -- Vincent Gabriel. Lead Developer, Senior Support. Zend Certified Engineer. Zend Framework Certified Engineer. -- http://www.vadimg.co.il/
