CakePHP Tip – Creating static page

There is an easy way of creating a static page in CakePHP. This tip allows also to create non-authenticated pages among applications that needs authentication.

For the purpose of this example, we will create a static page http://www.yourdomain.com/about.

1. Go to /app/config/routes.php, and add this line:

Router::connect(‘/about’, array(‘controller’ => ‘pages’, ‘action’ => ‘display’, ‘about’));

2. Now, you can create an actual page with a content that you want to display on your new static ‘about’ page. To do so, copy the file to:

/app/views/pages/about.ctp

Don’t forget to save this file with an extension /*.ctp.

3. You can now access this page at http://www.yourdomain.com/about