Skip to content

Kirby 5.1.1

$page->prevListed()

Returns the previous listed page

$page->prevListed(Kirby\Cms\Pages|null $collection = null): Kirby\Cms\Page|null

Parameters

Name Type Default
$collection Kirby\Cms\Pagesornull null

Return types

Kirby\Cms\Pageornull

This method modifies the existing $page object it is applied to and returns it again.

Parent class

Kirby\Cms\Page

Examples

<?php if ($prev = $page->prevListed()): ?>
<a href="<?= $prev->url() ?>">previous listed page</a>
<?php endif ?>

With collection as argument

<?php
$collection = $page->siblings()->listed()->sortBy('date', 'desc');
if ($prev = $page->prevListed($collection)): ?>
<a href="<?= $prev->url() ?>">previous listed page</a>
<?php endif ?>