Previous/next article

These little snippets let you create a useful prev/next switcher navigation for your pages.

Switch all visible pages of a folder

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

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

Switch all invisible pages of a folder

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

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

Switch all pages of a folder

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

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