Welcome Guest, Not a member yet? Register   Sign In
How to fix custom pagination codeigniter 4
#1

(This post was last modified: 03-27-2022, 07:01 PM by startup.)

1. app\config\pager.php
PHP Code:
'pagination'        => 'App\Views\Pagers\pagination'
2. controller
PHP Code:
$userModel = new UserModel();
        $data = [
            'users' => $userModel->paginate('5'),
            'pager' => $userModel->pager
        
]; 
3. view.php
PHP Code:
<div class="d-flex justify-content-end">
        <?php if ($pager) :?>
        <?php $pagi_path'/ciall/ci4/hmvc/home/users'?>
        <?php $pager->setPath($pagi_path); ?>
        <?= $pager->links('default','pagination'?>
        <?php endif ?>
      </div> 

PHP Code:
<nav aria-label="<?= lang('Pager.pageNavigation') ?>">
    <ul class="pagination demo">
        <?php if ($pager->hasPreviousPage()) : ?>
            <li>
                <a href="<?= $pager->getFirst() ?>" aria-label="<?= lang('Pager.first'?>">
                    <span aria-hidden="true"><?= lang('Pager.first'?></span>
                </a>
            </li>
            <li>
                <a 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="active"' '' ?>>
                <a href="<?= $link['uri'?>">
                    <?= $link['title'?>
                </a>
            </li>
        <?php endforeach ?>

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

ok i fixed it, thank you for seeing, i note fix above for everyone need
Reply




Theme © iAndrew 2016 - Forum software by © MyBB