Next Previous link with filter

Hi,

I would like to know if it’s possible to make Prev/Next page link with some filterby… for exemple : Next Page Visible, Unscheduled (plugin), template Article etc…

<?php if($previous = $page->prev()->visible()->unscheduled()->filterBy('template', '==', 'blogarticle')): ?>
    <a href="<?= $previous->url() ?>">previous articles</a>
<?php endif ?>

Thanks :slight_smile:

It’s possible with these two custom methods:


They allow you to pass the filtered collection as first argument.

<?php
$siblings = $page->siblings()->visible()->filterBy('template', '==', 'blogarticle')->unscheduled();
 if($previous = $page->getPrev($siblings)): ?>
    <a href="<?= $previous->url() ?>">previous articles</a>
<?php endif ?>

Thank you a lot @texnixe when I see the code you have made, I could not have done it alone !

:heavy_heart_exclamation: