Zend framework2不同的模块配置不同的布局如何配置呢
1个回答
展开全部
在当前模块的Module.php中添加onBootstrap(MvcEvent $e)
public function onBootstrap(MvcEvent $e)
{
$e->getApplication()->getEventManager()
->attach("dispatch", function ($e) {
$controller = $e->getTarget();
$c = get_class($controller);
if (__NAMESPACE__ === substr($c, 0, strpos($c, "\\")))
{
if (FALSE === $e->getViewModel()->terminate())
$controller->layout("layout/admin");
}
});
}
module.config.php中配置视图的那里添加配置
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'template_map' => array(
'layout/admin' => __DIR__ . '/../view/layout/layout.phtml',
),
'template_path_stack' => array(
'admin' => __DIR__ . '/../view',
),
),
public function onBootstrap(MvcEvent $e)
{
$e->getApplication()->getEventManager()
->attach("dispatch", function ($e) {
$controller = $e->getTarget();
$c = get_class($controller);
if (__NAMESPACE__ === substr($c, 0, strpos($c, "\\")))
{
if (FALSE === $e->getViewModel()->terminate())
$controller->layout("layout/admin");
}
});
}
module.config.php中配置视图的那里添加配置
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'template_map' => array(
'layout/admin' => __DIR__ . '/../view/layout/layout.phtml',
),
'template_path_stack' => array(
'admin' => __DIR__ . '/../view',
),
),
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询