Home » Php » php – How to know total pages of pagination in codeigniter 4

php – How to know total pages of pagination in codeigniter 4

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am using codeigniter 4, I created pagination in view and its display the results fine. But I want to know total page for this results. The view code for pagination is –

<?php if ($pager) :?>
   <?php $pagi_path=getenv('pagi_path').'search'; ?>
   <?php $pager->setPath($pagi_path); ?>
   <?= $pager->links() ?>
<?php endif ?>
How to&Answers:

$pager->getPageCount() – gives you total count of pages

Class is located in system/Pager/Pager.php , you can look it’s methods for even more ‘extras’