Pagination Recall

By Matt Curry (mattc)
Does it drive you nuts when you edit an item on page 4 of a list, then when you save you're dropped back to page 1 with the list back in the default order? The PaginationRecall component automatically remembers the page you were on and the sorting so you're returned to the same spot on the list.

 

Comments 612

CakePHP Team Comments Author Comments
 

Comment

1 Thanks for it

Your component is very useful. Many times when I modified something I was dropped to the first page. Now it's more comfortable :]
Posted Feb 5, 2008 by wokowy
 

Comment

2 Why not make use of the referer

For example many times I'll be paging through a sorted list of records and want to edit a particular one. After I edit and save I'm dropped back to the index with the default sorting on page 1. Hi, from the above description the problem could easily be avoided if instead of redirecting to the index, you redirected to (the referer url when they first entered the edit function) when the edit was finished.
The only time what i propose wouldn't work is if you are storing settings in the session.
Posted Feb 5, 2008 by Andy Dawson
 

Comment

3 Referer is good

I agree with Andy I have used that technique because it does not only redirects to the index it can redirect you from a diferent controller, anyway I think the component is nice.
Posted Feb 11, 2008 by Boris Barroso
 

Comment

4 RE Why not make use of the referer

...the problem could easily be avoided if instead of redirecting to the index, you redirected to (the referer url when they first entered the edit function) when the edit was finished.
Doh! I knew as soon as I published this someone would show me an easier way. Thanks for the tip Andy.
Posted Feb 16, 2008 by Matt Curry
 

Comment

5 thanks

Notice (8): Undefined index: url
Posted Mar 27, 2008 by z sw
 

Comment

6 Code

Not sure where the rest of the article went. If you're looking for the code it's available at http://github.com/mcurry/cakephp/tree/master/components/pagination_recall
Posted Nov 3, 2008 by Matt Curry
 

Comment

7 Referrer is not always reliable

I was using $referer until just recently a friend of mine pointed out that my code was not acting at all as expected on his machine. I found that his browser was passing the root of the site as the referrer and because of that, I'm quite happy to find this component which does not suffer this issue because of it's use of sessions rather than referrer, and I thank the author for writing it.

(After some research, I found that my friend was using a Firefox extension that purposely mangles his referrer data and does several other annoying things in the name of "security", but it does make one wonder how many other folk are using similar tools and blame their troubles with websites on the web designer rather than on their own choice of "security" tools. Something to think about...)
Posted Dec 15, 2008 by Silver Knight
 

Comment

8 THANKS SO MUCH - This is what you need for AJAX Pagination

Thanks so much for this component, I've been trying to get AJAX Pagination to work exactly as you described above. I cannot use the REFERER in the case of AJAX, because the URL for the referer is the base URL, not the URL with all of the sort parameters and page information in it... This worked as soon as I downloaded it. I wish I found it yesterday, I could have saved myself a HUGE headache :)

Posted Feb 19, 2009 by Tara Page
 

Comment

9 Easier way without using the session

To achieve the same thing without using the session, create your action link and pass the current page as a parameter like so:

$paginator->current()

Then in your controller, when you have completed what you need to, do this:

$this->redirect($this->referer()."/page:".$page);
where $page is the extra parameter you passed in above.
Posted May 3, 2009 by Dav