Show a calculated range of pages


#1

Hi,

is ist possible to show a calculated range of pages?

Example:
I have a page with a field called “year”. I need to display all pages with the same year +/- 10 years.

I already managed it to display pages with the same year with the following line:

<?php $werke = page('bibliothek/werke')->children()->filterBy('year',$page->year()->uri());?>

#2

Yes, you can do that with a filter with a callback

https://getkirby.com/docs/cheatsheet/pages/filter

More date based examples here: https://getkirby.com/docs/cookbook/filtering


#3

almost there…

but with this i get no results:

<?php $werke = page('bibliothek/werke')->children()->filterBy('year', '>', strtotime('year - 10'))->filterBy('year', '<', strtotime('year + 10'));?>

(i have set the field as number)


#4

That doesn’t make sense