Reputation: 67
I wish to implement pagination in my search results in the view page. Currently in the controller, I limit it to 10 results to view. How do I implement pagination?
In my controller,
var $name = 'Searches';
var $components = array('Auth');
var $uses = array('User','Passion');
$users = $this->User->find('all',array('limit'=>10,'conditions'=>$final_conditions,'fields'=>array('User.*')));
In my view page,
<?php foreach ($search_fields as $user): ?>
<tr>
<?php //debug($search_fields);?>
<td><?php echo $user['User']['firstName']; ?></td>
<td><?php echo $user['User']['lastName']; ?></td>
<td><?php echo $user['User']['email']; ?></td>
<td><?php echo $user['User']['displayName']; ?></td>
<td><?php echo $user['User']['gender']; ?></td>
</tr>
<?php endforeach; ?>
Upvotes: 0
Views: 2474
Reputation: 1387
Controller
$this->paginate = array(
'conditions' => $final_conditions,
'limit' => 10
);
$users = $this->paginate('User');
In the view you just use the same as on http://book.cakephp.org/view/166/Pagination-in-Views
Upvotes: 1