Reputation: 11
I was trying to add new error 404 page for my module. I have Application and my own Admin module. For Application I use default 404.phtml, for my new module I created admin404.phtml but I have no idea how to run it. There are a lot of options how to change layout for modules but I couldn`t find answer for my question. Can anyone help me?
Upvotes: 1
Views: 917
Reputation: 750
When a page could not be found or some other error happens inside of your web application,
a standard error page is displayed. The appearance of the error page is controlled by the
error templates. There are two error templates: error/404
which is used for "404 Page Not Found" error, and error/index
which is displayed when an unhandled exception is thrown somewhere inside of the application.
The module.config.php file contains several parameters under the view_manager
key, which you can use to configure the appearance of your error templates:
<?php
return array(
//...
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
//...
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
//...
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index'=> __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
);
display_not_found_reason
parameter controls whether to display the detailed
information about the "Page not Found" error.display_exceptions
parameter defines whether to display information about
an unhandled exception and its stack trace.not_found_template
defines the template name for the 404 error.exception_template
specifies the template name for the unhandled exception error.You typically set the display_not_found_reason
and display_exceptions
parameters
to false
in production systems, because you don't want site visitors see the details
about errors in your site. However, you will still be able to retrieve the detailed
information from Apache's error.log
file.
Upvotes: 2