I am creating a site with CakePHP, and I need to set some URLs for static pages, which are handled by the pages controller. Basically I want to have two different types of static pages, with the URLS
mysyte.com/page
which should map to app/views/pages/page.ctp and
mysite.com/special/page
which should map to app/views/pages/special-page.ctp. Note that in the first case page can be 'special' as well.
I am a bit lost with the routing I have to set up for this situation. I have tried to use the two routes
Router::connect(
'/special/:mypage',
array('controller' => 'pages', 'action' => 'display'),
array('pass' => array('mypage'), 'mypage' => '[a-z]+')
);
Router::connect('/*', array('controller' => 'pages', 'action' => 'display'));
and in the pages controller
function display($page = null, $mypage = null) {
if ($mypage) {
$path = array('special-'. $mypage);
}
else {
$path = func_get_args();
}
//The rest of the display action
}
The problem is that is seems that :mypage is passed as the first parameter in the action, which is page, and not as the mypage parameter.
How can I possibly fix this?