简体   繁体   中英

Pagination on url cakephp

I created an API using cakephp and I created a custom json output for get method . You can see below the output for a GET for a specific id

http://imgur.com/I3FSBC6

my url now is : localhost:8765/api/drones/6153/

my problem is how to custom the url so I can add the pagination and to change the url like localhost:8765/api/drones/6153/page:1

this my route's code :

 Router::connect('/api/drones/:id', ['controller' => 'Drones', 'action' => 'view', 'prefix' => 'api'],['id' => '\d+', 'pass' => ['id']]);

You just need to add one more parameter within the pass-> page

 Router::connect('/api/drones/:id', 
   ['controller' => 'Drones', 'action' => 'view', 'prefix' => 'api'],
   [
     'id'   => '\d+', 
     'pass' => ['id', 'page']       // Add page along with id
   ]
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM