1StopCoders

Code Examples and Industry News

Creating a Static Page with CakePHP

CakePHP - 0 Comments - Created by Casey Martin: 2014-05-10 20:11:00

In this example, we are going to create a sample About Us page. Write some text and save it as about_us.ctp. Static pages must be saved with a ".ctp" file extension, and rather than spaces, use underscores.

To set a page title, add the following line to your file:

$this->pageTitle = 'About Us';


To view the page, go to the following URL:
http://yourdomain.com/pages/about_us

If you would like to shorten the URL to exclude "pages", add the following line to app/config/routes.php:
Router::connect('/about_us', array('controller' => 'pages', 
'action' => 'display', 'about_us'));