$page->nextVisible() loop if page has checkbox selected

I have 10 subpages on a page.
8 of the 10 subpages have a checkbox selected in the cms.

I only want those 8 subpages to be in my next/previous flow.

I need something like: <?php if($next = $page->nextVisible() && $page->checkbox() == '1') ): ?>

Can someone help me?
Thanks!

Check the solution in this thread: Navigate into a collection with hasNext/hasPrev

Thanks for the fast response.
I’m very new at Kirby, so i need to make a new file under : plugins/collection.php and past it there?
And where do i need to check if the page contains a checked checkbox?

Thanks for the help!

You pass a filtered collection to the method, your collection would be:

$collection = $page->siblings(false)->filterBy('checkbox_field', '1');

The methods would go into /site/plugins/collection.php, in fact, it does not matter what you call the file, I usually call it methods.php.

I don’t think my function $page->getPrev is called correctly? i don’t get a return :frowning:

I’ll try to look into this later, but please do post code as code snippets, not images. We don’t really want to type everything in to test it. Thank you!:slight_smile: