无法呈现模板“错误”;解析器无法解析为ZF2文件

时间:2013-08-22 13:59:26

标签: zend-framework2

我已经看过已经针对这个主题讨论过的所有链接但似乎无法为我工作,因此我想再次打开这个讨论并向您展示我的配置文件..

首先,我的文件夹结构如下: enter image description here

到目前为止,我有这样的module.config.php:

    return array(
    'controllers' => array(
        'invokables' => array(
            'Album\Controller\Album' => 'Album\Controller\AlbumController',       
        ),
        'view_manager' => array(
            'template_map' => array(
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'album/album/index' => __DIR__ . '/../view/album/album/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
                ),
            'template_path_stack' => array(
                'album' => __DIR__ . '/../view',
            )
        )
    ),

    'router' => array(
        'routes' => array(
            'album' => array(
                'type'    => 'segment',
                'options' => array(
                    'route'    => '/album[/:action][/:id]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id'     => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'Album\Controller\Album',
                        'action'     => 'index',
                    ),
                ),
            ),
        ),
    ),

);

3 个答案:

答案 0 :(得分:3)

您可能有一个应用程序模块,其中有一个文件view/error/404.phtml。从相册模块中删除以下行(因此应用程序模块):

'error/404'   => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',

相关模块覆盖应用程序模块及其配置会发生什么。 “影集”模块是指“影集”模块中不存在的错误页面(请参阅相册中没有view/error/404.phtml file)。

如果您还删除了应用程序模块,请从骨架应用程序中取回它,一切都会再次运行。

答案 1 :(得分:0)

你忘了

    'not_found_template'       => 'error/404',
    'exception_template'       => 'error/index',
像那样:

'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',
        ),

答案 2 :(得分:0)

将此方法添加到Album \ Module.php

public function getConfig()
{
   return include __DIR__ . '/config/module.config.php';
}
相关问题