hasPrevListed() only for pages with toggle field is true

Hello!
I try to find a way to limit the $page->hasPrevListed() only to pages that has a toggle field turned to true.

I can’t figure out where should I insert the term of ->toggle()->‘true’ because it is not related to the $page but more reasonably to the PrevListed.

I tried this, but it doesn’t filter the pages at all:

<?php $myFilterPages = page('home')->children()->template('project')->listed()->toggle('true');?>
<?php if ($page->hasPrevListed($myFilterPages)): ?>'
           ...
<?php endif; ?>

I hope I’m understood
Thanks in advance!

Should be

<?php $myFilterPages = page('home')->children()->template('project')->listed()->filterBy('toggle', true);?>

If the field name is toggle, that is.

1 Like