2012年5月11日星期五

Evan Coury's Blog: Module-specific layouts in Zend Framework 2


Evan Coury has a new Zend Framework 2 related blog post looking at how to use module specific layouts in your application (even though, technically, it's more related to the controller).



There's really no such thing as "module-specific" anything in ZF2, so what we're really talking about is the topmost namespace of the controller being dispatched. So in the case of MyModuleControllerSomeController, the topmost namespace would be MyModle. In most cases, this will be the name of a given module.


He gives a quick piece of sample code showing a "Module" class that attaches an event on the dispatch of its request. Inside this event, he grabs the controller (target) and updates the layout via a call to the "layout" method. This is all handled in the "init" method of the module, so it should "just work" when the module is used.

没有评论:

发表评论