Skip to content

Instantly share code, notes, and snippets.

@tysongach
Forked from bastianallgeier/pagination.php
Last active December 13, 2015 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tysongach/4948479 to your computer and use it in GitHub Desktop.
Save tysongach/4948479 to your computer and use it in GitHub Desktop.
Pagination for Kirby with a link to each page. Utilizes PHP short tags.
<?
$list = $page->children()->paginate(10);
$pagination = $list->pagination();
?>
<ul>
<? foreach($list as $item): ?>
<li><!-- item html --></li>
<? endforeach ?>
</ul>
<nav>
<ul>
<? if($pagination->hasPrevPage()): ?>
<li><a href="<?= $pagination->prevPageURL() ?>">&larr;</a></li>
<? else: ?>
<li><span>&larr;</span></li>
<? endif ?>
<? foreach($pagination->range(10) as $r): ?>
<li><a<? if($pagination->page() == $r) echo ' class="active"' ?> href="<?= $pagination->pageURL($r) ?>"><?= $r ?></a></li>
<? endforeach ?>
<? if($pagination->hasNextPage()): ?>
<li class="last"><a href="<?= $pagination->nextPageURL() ?>">&rarr;</a></li>
<? else: ?>
<li class="last"><span>&rarr;</span></li>
<? endif ?>
</ul>
</nav>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment