Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesnt paginator remember my custom parameters when I go to page 2?

When using the paginator helper in cakephp views, it doesnt remember parts of the url that are custom for my useage.

For example:

http://example.org/users/index/moderators/page:2/sort:name/dir:asc

here moderators is a parameter that helps me filter by that type. But pressing a paginator link will not include this link.

like image 566
Alexander Morland Avatar asked Sep 29 '08 08:09

Alexander Morland


2 Answers

The secret is adding this line to your view:

$paginator->options(array('url'=>$this->passedArgs));

(I created this question and answer because it is a much asked question and I keep having to dig out the answer since i cant remember it.)

like image 152
Alexander Morland Avatar answered Oct 06 '22 13:10

Alexander Morland


To add to Alexander Morland's answer above, it's worth remembering that the syntax has changed in CakePHP 1.3 and is now:

$this->Paginator->options(array('url' => $this->passedArgs));

This is described further in the pagination in views section of the CakePHP book.

like image 31
Loftx Avatar answered Oct 06 '22 14:10

Loftx