Just an idea, not tested:
You could use an URL parameter to pass the tag to the project page. Instead of using the standard page methods, you could create your own custom page methods https://getkirby.com/docs/developer-guide/objects/page, that use the information from the parameter to determine the next/prev pages (custom page methods will be available in the upcoming 2.3 release).
Edit: That would in fact work if you copy the code from the protected methods _prev()
and _next()
into your own page methods. Then you can pass a filtered collection to those methods like this.
// the referer is passed from the projects overview page
<?php $referer = param('referer'); ?>
<nav class="nextprev cf" role="navigation">
<?php if($prev = $page->_prev($page->siblings()->filterBy('tags', $referer, ','))): ?>
<a class="prev" href="<?php echo $prev->url() . "/referer:" . $referer ?>">← previous</a>
<?php endif ?>
<?php if($next = $page->_next($page->siblings()->filterBy('tags', $referer, ','))): ?>
<a class="next" href="<?php echo $next->url() . "/referer:" . $referer ?>">next →</a>
<?php endif ?>
</nav>
Note that the above is just a rough outline to illustrate the idea using the native protected _prev()
and _next()
methods (by hacking the core to make them public for testing). Also, you would have to check if the referer exists etc.