Thu 24 Jan 2008
I’ve been using the built in pagination in CakePHP 1.2-beta a lot lately and I must say it’s freaking awesome. My one oh so minor grievance is that it doesn’t “remember” where you were if you navigate off the page. 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.
I Googled around a bit and skimmed through the pagination code, but didn’t see a quick way to turn this type of functionality on. So I wrote a quick component that keeps the sort/page in the session and re-applies it. This is all done automatically by just including the component in your controller.
You can download the component here.
I’ll probably submit it to the CakePHP Bakery soon, but was hoping to get some feedback first.
Popularity: 89% [?]











January 25th, 2008 at 3:43 am
Hi there,
this is an interesting and useful component, thanks for sharing. It’s amazing what you can accomplish with <50 lines of code using Cake.
And a small suggestion: if you’re proficient enough with the 1.2 pagination, why don’t you post some HOWTOs for it? Examples: pagination, pagination w/ AJAX, pagination of a child model, pagination of a child model w/ AJAX etc.. I’m sure there are plenty of folks out there (myself included) that are not familiar enough with pagination to use it well. We would be very grateful
Cheers!
January 25th, 2008 at 6:34 am
I’ve been pretty much just using the default settings for paginate. That’s part of the reason I posted this here before submitting it to the Bakery. I’m not sure how well it works in the other scenarios your described.
February 4th, 2008 at 4:32 pm
This code is now in the CakePHP Bakery:
http://bakery.cakephp.org/articles/view/pagination-recall