Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create a custom error page

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 535
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: