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”]<?php
View is in /views/pages/home.ctp
Router::connect(‘/’, array(‘controller’ => ‘pages’, ‘action’ => ‘display’, ‘home’));
?>[/code]
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”]<?php
View is in /views/pages/about/my_company.ctp
Router::connect( ‘/about/my-company’, array( ‘controller’ => ‘pages’,
‘action’ => ‘display’,
‘about’,
‘my_company’,
)
);
?>[/code]
The page title would be ‘My Company’ this time since underscores are converted to spaces. Pretty useful.