-
-
Save bugsysop/5785031 to your computer and use it in GitHub Desktop.
Kirby CMS : pagination
http://getkirby.com/forum/code-snippets/topic:76
This file contains hidden or 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