Question

When I use CakePHP Paging I get an url like this:

http://example.com/php/page:2

What do I have to change in the controller, the view and the routes.php to create a working url like this:

http://example.com/php/2
Was it helpful?

OTHER TIPS

Oh yes, now I see your question. Well you could do something like:

function index($page){
  $this->paginate = array('page'=>$page);
  $this->set('stuff', $this->paginate('YourControllerName'));
}

See here for more details: http://bakery.cakephp.org/articles/view/basic-pagination-overview-3

Also, of course you should do some validation that the page is an actual number and that the page would even exist but that is the basics of it i think.

About the routes and views, I have never tried but have a look at these posts on the cake groups, I think they have a problem similar to yours.

http://www.mail-archive.com/cake-php@googlegroups.com/msg45878.html

My guess is that this won't be easy to automate, you'll definitely need to do some tweaking.

For starters, you'll probably have to create your own paginator helper and inherit the default one. By the looks of the code, you'll need to override the link-generating code in PaginatorHelper::__pagingLink(), but probably numbers() and prev() etc.. since they all create links with the page param.

Maybe a better way would be to override your AppHelper::url(), check for the "page" param there and modify the url to accomodate your needs.

But, I haven't tried all this, so no guarantees..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top