I have a view with two different actions of the same model (An item list sorted by the most recent, and the same list sorted by the most popular). One list I want to paginate with 8 items at a time and one with 12 items at a time. I’m using AJAX to page in the items. How do I go about setting up the controller to handle this task? The problem seems to be that I can’t create two different pagination instances, so I can only paginate in the same number of items regardless of the action.
Thanks in advance for your help.
What I’ve tried so far
Basically trying to set limits specific to each action, rather than the initial pagination helper:
var $paginate = array('order'=>array('Category.name'), 'limit'=>'8');
That’s what the helper looks like, and it feeds in whatever the limit is. Even if I remove that limit and try to apply it like so:
var $paginate = array('order'=>array('Item.name'));
function discover_list(){
$this->set('d_ajax_items', $this->paginate('Item', array('Item.discover_order' => null, 'Item.moderated' => 1), null, 'Item.id DESC', null, 8));
}
function trend_paging(){
$this->set('trend_items', $this->paginate('Item', array('Item.moderated' => 1),NULL, 'rank DESC', NULL, 12));
}
The limit on the end of the action is ignored, and it feeds in some default 20 items at a time
I misunderstood your original question. If you want to set different limits to each action, you can do this
Edit
A little nice way