In Cakephp we have some default error pages but we can create our own error page. Here we will create a custom error page to show error if controller not found. If controller not found then we will show 404 error page. Below are few steps for creating custom error page
First create a error.ctp file for layout if you want to show error page with different UI
Open appController.php under /app/Controller and add the below code
function beforeRender() {
$this->setErrorLayout();
}
function setErrorLayout() {
if ($this->name == 'CakeError') {
$this->layout = 'error';
}
}
Now open /app/View/Error directory and create a file name as missing_controller.ctp and put your content in this file whatever you want to show
done now you can test it by putting any non existing URL
0 Comment(s)