I\'m working on a ZF2 Project, and I have some modules in my directories :
/module/module1
/module/module2
/module/module3
/module/module4
[...]
You can set the layout to be what ever you want in each modules config, just change the layout to be what ever you want:
module.config.php or inside getConfig()
'view_manager' => array(
// other stuff here..
'template_map' => array(
// use Applications layout instead
'layout/layout' => __DIR__ . '/../Application/view/application/layout/layout.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
Or you can set each module to selectively set it's layout in Module.php:
Module.php
/**
* Initialize
*/
public function init(ModuleManager $manager)
{
$events = $manager->getEventManager();
$sharedEvents = $events->getSharedManager();
$sharedEvents->attach(__NAMESPACE__, 'dispatch', function($e) {
/* @var $e \Zend\Mvc\MvcEvent */
// fired when an ActionController under the namespace is dispatched.
$controller = $e->getTarget();
$routeMatch = $e->getRouteMatch();
/* @var $routeMatch \Zend\Mvc\Router\RouteMatch */
$routeName = $routeMatch->getMatchedRouteName();
$controller->layout('application/layout/layout');
}, 100);
}