Welcome Guest, Not a member yet? Register   Sign In
Pagination - show number results on current page
#8

Ok guy's this is how I' am doing it in my new blog I' am working on.

PHP Code:
<!-- Pagination Views/pagination.php include this view in your view or layout. -->
<
div class="pagination justify-content-center mb-4">
    <?php if ( ! empty($pager)) :
        //echo $pager->simpleLinks('group1', 'bs_simple');
        echo $pager->links('group1''bs_full');
    endif ?>

    <!-- Bootstrap 5.1.3 code to show page 1 of 4 total pages using a button. -->
    <div class="btn-group pagination justify-content-center mb-4" role="group" aria-label="pager counts">
        &nbsp;&nbsp;&nbsp;
        <!-- NOTE: $currentPage and $totalPages are set in the Controllers $data and passed in to the view. -->
        <button type="button" class="btn btn-light"><?= 'Page '.$currentPage.' of '.$totalPages?></button>
    </div>
</div> <!-- End of pagination -->

// Controller
$data = [
    'pager'      => $posts->pager,
    'currentPage' => $posts->pager->getCurrentPage('group1'),
    'totalPages'  => $posts->pager->getPageCount('group1'),
]; 

Make sure you read the comments in the code.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: Pagination - show number results on current page - by InsiteFX - 02-06-2022, 01:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB