Skip to content

Kirby 3.5.7.1

$page->next()

Returns the next item in the collection if available

$page->next(\Kirby\Cms\Collection|null $collection = null): Kirby\Cms\Model|null

Parameters

Name Type Default
$collection Kirby\Cms\Collection|null null

Return type

Kirby\Cms\Model|null

Parent class

Kirby\Cms\Page

Example

<?php if($next = $page->next()): ?>
<a href="<?= $next->url() ?>">next page</a>
<?php endif ?>

Pass a collection

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