ZF2 - How to change the error/404 response page? Not just template but to set a new ViewModel

前端 未结 7 2566
离开以前
离开以前 2021-01-05 22:46

By default the page is set like this in the Application module.config array:

\'template_map\' => array(
    \'error/404\' => __DIR__ . \'/         


        
7条回答
  •  猫巷女王i
    2021-01-05 23:22

    The First thing is to create the views :

    modules/Yourapplication/view/yourapplication/error/index.phtml

    modules/Yourapplication/view/yourapplication/error/404.phtml

    The second thing is to register the views in the module config:

    In module.config.php of your application

    'view_manager' => array(
            //[...]
            'not_found_template'       => 'error/404',
            'exception_template'       => 'error/index',
            'template_map' => array(
            //[...]
            'error/404'   => __DIR__ . '/../view/yourapplication/error/404.phtml',
            'error/index' => __DIR__ . '/../view/yourapplication/error/index.phtml',
            ),
       // [...]
        ),
    

提交回复
热议问题