Hi there,
I am using the hasPrevListed/hasNextListed function to checks if there’s a previous listed page in the siblings collection:
This works fine until I get into the last or first project of a collection. Then he/she (the website) moves on to another collection/category.
Does anyone know how to prevent this?
And in addition to this question. A project can has multiple categories. I only want to show the next project in the category (collection) in which the visitor has entered the project. Is this even possible?
My code:
<ul class="pagination">
<?php $collection = $page->siblings()->listed(); if ($page->hasPrevListed($collection)): ?>
<li class="prev">
<a href="<?= $page->prevListed($collection)->url() ?>"><span class="text">Previous project</span> </a>
</li>
<?php endif ?>
<?php $collection = $page->siblings()->listed(); if ($page->hasNextListed($collection)): ?>
<li class="next">
<a href="<?= $page->nextListed($collection)->url() ?>"><span class="text">Next project</span> </a>
</li>
<?php endif ?>
</ul>
Thanks!