CakePHP error 404
How can I have a custom layout for a 404 page in Cake? I know you can create your own view but I also want a custom layout for it as I don't want it inheriting my site design and want it to have a unique look and fe开发者_StackOverflow社区el.
I've created my own views and then added my own app_error
in /app/
with the following code:
<?php
class AppError extends ErrorHandler
{
function error()
{
$this->layout = 'error';
}
}
?>
But it doesn't load the error layout? Any ideas why?
Thanks.
Create your own AppError
class (in app/app_error.php
and override the _outputMessage
method, something like:
class AppError extends ErrorHandler {
function _outputMessage($template) {
$this->controller->render($template, 'NAME OF THE LAYOUT');
$this->controller->afterFilter();
echo $this->controller->output;
}
}
I believe you just create a file at /views/errors/error404.thtml
. It may end in .ctp
actually, but give both a shot.
Create/edit the app/views/errors/error404.ctp
page. See CakePHP Error Handling.
精彩评论