Pagination:
It is used to limit the number of records to be displayed in a page. In cakephp we can easily implement pagination. We can use pagination by putting the following code in controller:
public $paginate = [
'limit' => 3, //restricting the number of records to be displayed in a page
'order' => [
'Users.id' => 'asc'
]
];
And we have to put the following code in that function where we will display data.
public function detail() {
// $det = $this->User->find('all',array('fields'=>array('User.id','User.name','User.phone','User.email','User.pic')));
$det=$this->paginate('User');
//set products data and pass to the view
$this->set('registers',$det);
}
And put the following links in view:
<?php echo $this->Paginator->numbers(); ?>
<?php echo $this->Paginator->prev(' Previous', null, null, array('class' => 'disabled')); ?>
<?php echo $this->Paginator->next('Next ', null, null, array('class' => 'disabled')); ?>
<?php echo $this->Paginator->counter(); ?>
0 Comment(s)