Friday, February 3, 2012

Re: Combined pagination between 2 models possible?

The paginator is just a shortcut to getting the count and limiting your results, so you can essentially pass any conditions you would in a normal find. This means for joins, like belongsTo, you can.

For example with Profile belongsTo User you could sort by Profile and User fields, assuming your pass recursive to your pagination options to include the models.

Additionally, for complex pagination, you can add a "paginate" method to your model and paginate using that method instead. Your controller code would look like:

// note we're passing the model object here
$this->Paginator->paginate($this->MyModel);

Then on your model

class MyModel extends AppModel {
  function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra) {
    //special pagination
  }
}


--
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: