Content.exe
To enable a different layout in a module, to your module.php for the module define a new layout like so
public function init(ModuleManager $mm)
{
$mm->getEventManager()->getSharedManager()->attach(__NAMESPACE__, 'dispatch', function($e) {
$e->getTarget()->layout('admin/layout');
});
}
then within your module.config.php view_manager settings define the template
'view_manager' => array(
'template_map' => array(
'admin/layout' => __DIR__ . '/../view/layout/cms.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
or you can define a direct path in your module.php without any template mapping i.e
public function init(ModuleManager $mm)
{
$mm->getEventManager()->getSharedManager()->attach(__NAMESPACE__, 'dispatch', function($e) {
$e->getTarget()->layout('layout/admin');
});
}
This will load module/view/layout/admin.phtml when this module is run
5 responses to “ZF2 different layouts in modules”