Welcome Guest, Not a member yet? Register   Sign In
Hide pager when only 1 page of results
#4

(This post was last modified: 10-05-2023, 02:06 PM by JoosepK.)

(04-19-2023, 03:54 AM)CarmosKarrvx Wrote: CodeIgniter 4 provides a built-in solution for hiding pagination links when there are results for only one page. You can use the hasMore method of the Pager class to check if there are more pages available. If there is only one page, then this method will return false. You can use this to conditionally display the pagination links in your view.

Here's an example code snippet that demonstrates how to do this:

<?php if ($clients->hasMore()): ?>
    <div class="pagination">
        <?= $clients->links() ?>
    </div>
<?php endif; ?>
In this example, we're using the hasMore method to check if there are more pages available. If there are, then we display the pagination links using the links method of the Pager class. If there is only one page, then the pagination links will not be displayed.

Thank you!

(04-12-2023, 01:44 PM)digitalarts Wrote: This is what I use:
PHP Code:
if ( $pager->getPageCount() > ) {
     echo $pager->links();
 } 
Thank you!
Reply


Messages In This Thread
RE: Hide pager when only 1 page of results - by JoosepK - 10-05-2023, 02:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB