I’m running in a problem with cakephp pagination. Currently, my pagination is rather standard. After x results, it creates a second page. And so on.
What i would like to do is to order them by month. As it is a news archive, I would like to be able to select the month instead of the page.
So instead:
- Page 1
- Page 2
- Page 3
I would like to have:
- January 2010
- February 2010
- March 2010
How is this possible? I can’t seem to find it. My current code:
var $paginate = array(‘limit’ => 50, ‘page’ => 1, ‘order’=>array(‘Newsitem.created’=>’DESC’));
thanks in advance!!
Pagination is a function of LIMIT row counts and offsets of number of records, not by data conditions. Therefore, you will not be able to use the pagination function in cake to accomplish this. You will need to create a custom solution to accomplish this. If you continue to solve this with the build in cake pagination, you will continue to hit a brick wall.
Now, that being said, one solution is to paginate by month. So you could have different links down the left showing the months (i.e. January 2010, February 2010, etc.), when they select one of those options, it will paginate all of the results for the given date.