CakePHP’s built-in Pages Controller

CakePHP 1.2 comes with in built PagesController which helps you easily create static pages. It’s easy to set up, you just have to put your pages view in /views/pages/. All the codes are for routes.php.

[code lang=”php”] ‘pages’, ‘action’ => ‘display’, ‘home’));

The page title ($pageTitle) would be ‘Home’ for the above.

If you want your URL to be /about/my-company, you can do the following:

[code lang=”php”] ‘pages’,
‘action’ => ‘display’,

The page title would be ‘My Company’ this time since underscores are converted to spaces. Pretty useful.

Leave a Reply

Your email address will not be published. Required fields are marked *