Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP custom route pagination

I would like to format my URL like so:

/news/index/page:2

to

/news/2

I would like to achieve this result by using as less code as possible (perhaps only from routes.php?), without modifying how the PaginatorHelper behaves.

Thank you for your help!

like image 600
linkyndy Avatar asked Jul 23 '26 23:07

linkyndy


1 Answers

This should work

// Add this to /app/config/routes.php
Router::connect('/news/:page', array('controller' => 'news', 'action' => 'index'));
like image 55
Ish Avatar answered Jul 28 '26 06:07

Ish