Created
July 19, 2012 13:23
-
-
Save bastianallgeier/3143887 to your computer and use it in GitHub Desktop.
Kirby range pagination with a link for each page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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() ?>">←</a></li> | |
<?php else: ?> | |
<li><span>←</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() ?>">→</a></li> | |
<?php else: ?> | |
<li class="last"><span>→</span></li> | |
<?php endif ?> | |
</ul> | |
</nav> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment