您可以在每个模块配置中将布局设置为您想要的任何内容,只需将布局更改为您想要的任何内容:
module.config.php 或内部 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',
),
),
或者您可以设置每个模块以选择性地在 Module.php 中设置其布局:
模块.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);
}