Welcome Guest, Not a member yet? Register   Sign In
How do I replace the default pagination with a pager?
#3

Sorry, I just remembered that I had created a Bootstrap bs_simple.php Pager template for it
Here are the templates for bootstrap. You will need to configure then in the app/Config/Pager.php file.
PHP Code:
<?php

/**
 * ./app/Views/Pager/bs_full.php
 * Bootstrap 4 or 5 Pager Template.
 * Renders the full Bootstrap pager links
 *
 * @var PagerRenderer $pager
 */

use CodeIgniter\Pager\PagerRenderer;

$pager->setSurroundCount(2);
?>
<nav aria-label="<?= lang('Pager.pageNavigation'?>">
    <ul class="pager pagination justify-content-center">
        <?php if ($pager->hasPreviousPage()) : ?>
            <li class="page-item">
                <a class="page-link" href="<?= $pager->getFirst() ?>" aria-label="<?= lang('Pager.first'?>">
                    <span aria-hidden="true"><?= lang('Pager.first'?></span>
                </a>
            </li>
            <li class="page-item">
                <a class="page-link" href="<?= $pager->getPreviousPage() ?>" aria-label="<?= lang('Pager.previous'?>">
                    <span aria-hidden="true"><?= lang('Pager.previous'?></span>
                </a>
            </li>
        <?php endif ?>

        <?php foreach ($pager->links() as $link) : ?>
            <li <?= $link['active'] ? 'class="page-item active"' '' ?>>
                <a class="page-link" href="<?= $link['uri'?>"><?= $link['title'?></a>
            </li>
        <?php endforeach ?>

        <?php if ($pager->hasNextPage()) : ?>
            <li class="page-item">
                <a class="page-link" href="<?= $pager->getNextPage() ?>" aria-label="<?= lang('Pager.next'?>">
                    <span aria-hidden="true"><?= lang('Pager.next'?></span>
                </a>
            </li>
            <li class="page-item">
                <a class="page-link" href="<?= $pager->getLast() ?>" aria-label="<?= lang('Pager.last'?>">
                    <span aria-hidden="true"><?= lang('Pager.last'?></span>
                </a>
            </li>
        <?php endif ?>
    </ul>
</nav>

// -----------------------------------------------------------------------------------------------------------

<?php

/**
 * ./app/Views/Pager/bs_simple.php
 * Bootstrap 4 or 5 Pager Template.
 * Renders just the Previous and Next link buttons.
 *
 * @var PagerRenderer $pager
 */

use CodeIgniter\Pager\PagerRenderer;

$pager->setSurroundCount(0);
?>
<nav aria-label="<?= lang('Pager.pageNavigation'?>">
    <ul class="pager pagination justify-content-center">
        <li <?= $pager->hasPrevious() ? 'class="page-item active"' 'class="page-item disabled"' ?>>
            <a class="page-link" href="<?= $pager->getPrevious() ?? '#' ?>" aria-label="<?= lang('Pager.previous'?>">
                <span aria-hidden="true"><?= lang('Pager.newer'?></span>
            </a>
        </li>
        <li <?= $pager->hasNext() ? 'class="page-item active"' 'class="page-item disabled"' ?>>
            <a class="page-link" href="<?= $pager->getnext() ?? '#' ?>" aria-label="<?= lang('Pager.next'?>">
                <span aria-hidden="true"><?= lang('Pager.older'?></span>
            </a>
        </li>
    </ul>
</nav> 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: How do I replace the default pagination with a pager? - by InsiteFX - 09-30-2021, 02:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB