
A simple way to order results in a pagination query
May 29, 2007In the controller, put this piece of code:
$this->paginate = array('order' => 'Topic.created DESC');
$this->set('topics', $this->paginate(array('Topic.board_id' => $id)));

In the controller, put this piece of code:
$this->paginate = array('order' => 'Topic.created DESC');
$this->set('topics', $this->paginate(array('Topic.board_id' => $id)));
Somehow i missed the point. Probably lost in translation
Anyway … nice blog to visit.
cheers, Shankar.
Hmm, it looks confusing to me now too
I think I was trying to order the results on Topic.created DESC and once that was set, you pass the topics variable as you would normally.
Thanks!!! I’ve been looking for a way to change the display order based on different paginated models in the same controller. i was starting to think cakePHP’s native pagination support couldn’t do this… simply and eloquent.
thanks for this, after 2 hours of headache.
many thanks!!!