php - 配置 ZF2 view_manager 以加载 2 个单独的模板映射

标签 php zend-framework2 zend-framework-modules

我在 ZF2 中需要 2 个不同的模板映射,一个用于管理,一个用于前端,目前从我所看到的 ZF2 合并了我配置的 2 个模块中使用的 2 个 module.config.php 文件,并导致我需要为管理员设置的模板映射,也将在前端模块中加载。

/Application module.config.php

...
'view_manager' => array(
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => array(
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
...

/admin module.config.php

...
'view_manager' => array(
        'template_path_stack' => array(
            'admin' => __DIR__ . '/../view',
        ),
        'template_map' => array(
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
        ),
    ),
...

我应该修改什么以便我可以为 2 个单独的模块加载单独的“view_manager”数组?

最佳答案

如果您能解释为什么要尝试实现这一目标,那就太好了。如我所见,您正在尝试为管理员设置不同的布局。也许你想看看这个已经可以做你正在尝试的模块 https://github.com/zf-commons/zfcadmin .该模块具有管理路由的布局设置。

关于php - 配置 ZF2 view_manager 以加载 2 个单独的模板映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13418739/

相关文章:

php - HTML5音频元素

zend-framework2 - 带有自定义验证器的 PHPUnit ZF2 输入过滤器

zend-framework - 默认模块中 Controller 的命名空间/前缀

php - Zend Framework 2 中的 OAuth

php - 在 ZF2 中直接将 PhpRenderer 与 subview 一起使用

php - Zend Framework - 重定向到不同模块中的 IndexController

javascript - 使用 PHP JSON 编码将数据发送到 jQuery getJSON 的奇怪行为

php - 如何在html多选框中输入php数据

php - 在 Debian 中将 PHP 脚本作为守护进程运行

php - 在 zf2 左连接中应用多个条件