In my Cake application I have a controller "completed_projects". Its index action takes no arguments and lists some projects. Different pages can be accessed by
example.com/completed_projects/index/page:23
etc.
I want to make the url's like this:
example.com/portfolio/page23
Obviously I need to make some routes for this. I've tried many of them like:
Router::connect('/portfolio/page:num', array('controller' => 'completed_projects', 'action' => 'index'), array('pass'=>'page:num', 'num'=>'[0-9]+'));
and also:
Router::connect('/portfolio/:page:num', array('controller' => 'completed_projects', 'action' => 'index'), array('named'=>'num', 'page'=>'page', 'num'=>'[0-9]+'));
I also tried modifying them again and again but none of them works well.
I am using CakePHP 1.3. Any help will be appreciated.
Router::connect('/portfolio/page:page_num',
array('controller'=>'completed_projects', 'action'=>'index'),
array('page_num'=>'[\d]+')
);
In your controller, access page_num with:
$this->params['page_num'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With