Require Kirby 2.3 Beta+
Version 0.1
Add pagejump
folder into /site/plugins/
.
In a template or a snippet it's possible to use $page->prev()
and $page->next()
. When at the end of a collection you will be hit by the end wall.
Sometimes it can be good not be bound by the walls. When using $page->jump($steps)
you can step any direction and always get a page.
It's similar to how an image slider or an ad rotator works.
Echo the title of the previous page.
$item = $page->jump(-1);
echo $item->title();
Echo the title of the next page.
$item = $page->jump(1);
echo $item->title();
Echo the title of the 5th page.
$item = $page->jump(5);
echo $item->title();
A real example. Go to the next page or the previous one, without hitting the end "wall".
<a href="<?php echo $page->jump(-1)->url(); ?>">
<?php echo $page->jump(-1); ?>
</a>
<a href="<?php echo $page->jump(1)->url(); ?>">
<?php echo $page->jump(1); ?>
</a>
To get an idea of how it works, look at the slider arrows on getkirby.com. The arrows are not links but the result is similar, a page rotator.