-
-
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.
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
<? | |
$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() ?>">←</a></li> | |
<? else: ?> | |
<li><span>←</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() ?>">→</a></li> | |
<? else: ?> | |
<li class="last"><span>→</span></li> | |
<? endif ?> | |
</ul> | |
</nav> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment