I am using cakephp framework . I have 10 items in one page and 5 items in 2nd page. The items are coming dynamically fetched from database. I want to show the number of items in per page
For Example:
1st page contains 10 items I want output : 1 of 10
2nd page contains 5 items
I want output : 11 of 15
Can anyone tell me what will i do in coding i am using pagination in that case.
My code is as follow :
<?php echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled')); ?>
<?php echo $this->Paginator->numbers(); ?>
<?php echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled')); ?>
You should have mentioned the version you're using.
For CakePHP 3, refer to Creating a page counter in CakePHP 3.x
echo $this->Paginator->counter('{{start}} of {{end}}'); // 1 of 10 (for page 1)
For CakePHP 2, refer to Creating a page counter in CakePHP 2.x
echo $this->Paginator->counter('{:start} of {:end}');
You can implement the below code:
Setting 'format' to range would output like '1 - 5 of 15':
echo $this->Paginator->counter(array(
'format' => 'range'
));
For more information please visit cakebook Paginator helper http://book.cakephp.org/3.0/en/views/helpers/paginator.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.