Tuesday, March 29, 2011

Paginate pre-ordered list

I need to paginate a list of results having the search return the results in the order I presented the list to the search. I'm trying to paginate a list of users but I'm using a separate table to define the order, there is no column in the users table to use for the order. 

Here is an example of what I mean: 

$liked = $this->Like->getMostLiked(); // <-- returns a pre-ordered list the way I want
$this->loadModel('User');
$like_list = array(); 
foreach ($liked as $user):
$list = $this->User->find('first', array(
'contain' => array('Like'),
'conditions' => array('User.id' => $user )));
array_push($like_list, $list);
endforeach;
echo debug($like_list); die;  // <-- returns the list of results in exactly the order I want

The only real problem I'm having is that I need my results to be paginated. I played around with custom pagination but things are not working out the way that I would like. 

Thanks in advance, 
ED 

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: