Ive been messing around with it a bit and got this, is this the right way to do things?
class DashboardController extends AppController { var $uses = array('Friend'); // Pagination var $paginate = array( 'Friend' => array( 'limit' => 5, 'order' => array('Friend.requestTime' => 'ASC'), 'recursive' => -1 ) ); function index() { $this->paginate['Friend'] = array('extra' => array('user_id' => $this->Auth->user('id'))); debug($this->paginate('Friend', array('Friend.status' => 'approved'))); } } And the custom paginate query: function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null, $extra = array()) { $conditions[] = array('OR' => array( 'Friend.user_id' => $extra['extra']['user_id'], 'Friend.friend_id' => $extra['extra']['user_id'] )); $results = $this->findAll($conditions, $fields, $order, $limit, $page, $recursive); $cleanResults = array(); if (!empty($results)) { foreach ($results as $friend) { if ($friend['Friend']['friend_id'] != $extra['extra']['user_id']) { $friend_id = $friend['Friend']['friend_id']; } else { $friend_id = $friend['Friend']['user_id']; } $userObj = $this->User->find('first', array( 'fields' => array('User.id', 'User.username', 'User.avatar', 'User.handle', 'User.country_id', 'User.signupDate'), 'recursive' => -1, 'conditions' => array('User.id' => $friend_id) )); if (!empty($userObj)) { $cleanResults[] = array_merge($friend, $userObj); } } } return $cleanResults; } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---