How to create a custom error page

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

  1. function beforeRender() {
  2. $this->setErrorLayout();
  3. }
  4. function setErrorLayout() {
  5. if ($this->name == ‘CakeError’) {
  6. $this->layout = ‘error’;
  7. }
  8. }

– See more at: http://findnerd.com/list/view/How-to-create-a-custom-error-page/3470/

For any  issue about PHP Programming Questions and Answers you can Visit to our  PHP Developer Forum

Advertisements
How to create a custom error page

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s