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="<?php echo $page->prevVisible()->url() ?>">previous page</a>
<?php endif ?>

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

Switch all invisible pages of a folder

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

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

Switch all pages of a folder

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

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