![]() |
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. |
Messages In This Thread |
Hide pager when only 1 page of results - by JoosepK - 04-04-2023, 01:21 PM
RE: Hide pager when only 1 page of results - by digitalarts - 04-12-2023, 01:44 PM
RE: Hide pager when only 1 page of results - by JoosepK - 10-05-2023, 02:03 PM
RE: Hide pager when only 1 page of results - by CarmosKarrvx - 04-19-2023, 03:54 AM
|