Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Created July 19, 2012 13:23
Show Gist options
  • Save bastianallgeier/3143887 to your computer and use it in GitHub Desktop.
Save bastianallgeier/3143887 to your computer and use it in GitHub Desktop.
Kirby range pagination with a link for each page
<?php
$list = $page->children()->paginate(10);
$pagination = $list->pagination();
?>
<ul>
<?php foreach($list as $item): ?>
<li><!-- item html --></li>
<?php endforeach ?>
</ul>
<nav>
<ul>
<?php if($pagination->hasPrevPage()): ?>
<li><a href="<?php echo $pagination->prevPageURL() ?>">&larr;</a></li>
<?php else: ?>
<li><span>&larr;</span></li>
<?php endif ?>
<?php foreach($pagination->range(10) as $r): ?>
<li><a<?php if($pagination->page() == $r) echo ' class="active"' ?> href="<?php echo $pagination->pageURL($r) ?>"><?php echo $r ?></a></li>
<?php endforeach ?>
<?php if($pagination->hasNextPage()): ?>
<li class="last"><a href="<?php echo $pagination->nextPageURL() ?>">&rarr;</a></li>
<?php else: ?>
<li class="last"><span>&rarr;</span></li>
<?php endif ?>
</ul>
</nav>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment