hasPrevious example

/** * Returns a URL to the "previous" page. The previous page is NOT the * page before the current page, but is the page just before the * "first" page. * * You MUST call hasPrevious() first, or this value may be invalid. * * @return string|null */
    public function getPrevious()
    {
        if ($this->hasPrevious()) {
            return null;
        }

        $uri = clone $this->uri;

        if ($this->segment === 0) {
            $uri->addQuery($this->pageSelector, $this->first - 1);
        } else {
            $uri->setSegment($this->segment, $this->first - 1);
        }

        
<?php
use CodeIgniter\Pager\PagerRenderer;

/** * @var PagerRenderer $pager */
$pager->setSurroundCount(0);
?> <nav> <ul class="pager"> <li <?= $pager->hasPrevious() ? '' : 'class="disabled"' ?>> <a href="<?= $pager->getPrevious() ?? '#' ?>" aria-label="<?= lang('Pager.previous') ?>"> <span aria-hidden="true"><?= lang('Pager.newer') ?></span> </a> </li> <li <?= $pager->hasNext() ? '' : 'class="disabled"' ?>> <a href="<?= $pager->getnext() ?? '#' ?>" aria-label="<?= lang('Pager.next') ?>"> <span aria-hidden="true"><?= lang('Pager.older') ?></span> </a> </li> </ul> </nav>


use CodeIgniter\Pager\PagerRenderer;

/** * @var PagerRenderer $pager */
$pager->setSurroundCount(0);

if ($pager->hasPrevious()) {
    echo '<link rel="prev" href="' . $pager->getPrevious() . '">' . PHP_EOL;
}

echo '<link rel="canonical" href="' . $pager->getCurrent() . '">' . PHP_EOL;

if ($pager->hasNext()) {
    echo '<link rel="next" href="' . $pager->getNext() . '">' . PHP_EOL;
}

use CodeIgniter\Pager\PagerRenderer;

/** * @var PagerRenderer $pager */
$pager->setSurroundCount(2);
?> <nav aria-label="<?= lang('Pager.pageNavigation') ?>"> <ul class="pagination"> <?php if ($pager->hasPrevious()) : ?> <li> <a href="<?= $pager->getFirst() ?>" aria-label="<?= lang('Pager.first') ?>"> <span aria-hidden="true"><?= lang('Pager.first') ?></span> </a> </li> <li> <a href="<?= $pager->getPrevious() ?>" aria-label="<?= lang('Pager.previous') ?>"> <span aria-hidden="true"><?= lang('Pager.previous') ?></span> </a> </li> <?php endif ?>
Home | Imprint | This part of the site doesn't use cookies.