How to paginate multiple results in CakePHP?


Nice

Sourabh Jain

Here is my solution. In your controller :

function index(){// Your default model
    $this->set('model1', $this->paginate());// Pagination for model2
    $this->set('model2', $this->paginate('Model2'));}

In your view :

// Display your model1 data, and then for prev and next 
echo $paginator->prev($options = array('model'=>'Model1'));
echo $paginator->next($options = array('model'=>'Model1'));
The point is input your model name to Controller's paginate method and to Paginator's link method (sort, prev, next).

// Display your model2 data, and then for prev and next 
echo $paginator->prev($options = array('model'=>'Model2'));
echo $paginator->next($options = array('model'=>'Model2'));

View original post

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s