# Section filters

**URL:** <https://forum.getkirby.com/t/section-filters/29603>\
**Category:** Questions\
**Tags:** v4\
**Created:** [September 28, 2023, 10:04am UTC](https://forum.getkirby.com/t/section-filters/29603 "2023-09-28T10:04:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_sr](https://avatars.discourse-cdn.com/v4/letter/_/47e85d/32.png) [@\_sr](https://forum.getkirby.com/u/_sr)\
**Post date:** [September 28, 2023, 10:04am UTC](https://forum.getkirby.com/t/section-filters/29603/1 "2023-09-28T10:04:09Z")

</div>

It’s nice that section filters are coming to kirby 4!

I tried to filter pages by the current date with the help of a page method or page model. But it doesn’t seem to work.

```auto
query: site.childrenAndDrafts.filter('dateStart', '>=', '{{ page.now }}')

```

It works perfectly with a string, f.ex.

```auto
query: site.childrenAndDrafts.filter('dateStart', '>=', '2023-09-28')

```

Are just static values allowed like in the example on the website, or is there something I missed?

> **[Pages section](https://getkirby.com/docs/reference/panel/sections/pages#filtering-pages__query)**
>
> List and edit subpages

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 28, 2023, 10:36am UTC](https://forum.getkirby.com/t/section-filters/29603/2 "2023-09-28T10:36:22Z")

</div>

> [@\_sr](#):
>
> `page.now `

Is that your model method?

---

<div class="post-metadata">

**Author:** ![\_sr](https://avatars.discourse-cdn.com/v4/letter/_/47e85d/32.png) [@\_sr](https://forum.getkirby.com/u/_sr)\
**Post date:** [September 28, 2023, 10:54am UTC](https://forum.getkirby.com/t/section-filters/29603/3 "2023-09-28T10:54:36Z")

</div>

Yes, `page.now` is the model in this case. But I tried it also with a method.

The model looks like this:

```auto
class ExhibitionPage extends Page {
    public function now()
    {
        return date('Y-m-d');
    }
}

```

Both method or model works fine if I want to display it in the list item like `info: '{{ page.now }}'`

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 28, 2023, 11:00am UTC](https://forum.getkirby.com/t/section-filters/29603/4 "2023-09-28T11:00:35Z")

</div>

To compare a date value, try using `date >=` as comparison operator

```auto
query: site.childrenAndDrafts.filter('dateStart', 'date >=', '{{ page.now }}')

```

---

<div class="post-metadata">

**Author:** ![\_sr](https://avatars.discourse-cdn.com/v4/letter/_/47e85d/32.png) [@\_sr](https://forum.getkirby.com/u/_sr)\
**Post date:** [September 28, 2023, 11:15am UTC](https://forum.getkirby.com/t/section-filters/29603/5 "2023-09-28T11:15:10Z")

</div>

Sadly, it doesn’t work…

---

<div class="post-metadata">

**Author:** ![\_sr](https://avatars.discourse-cdn.com/v4/letter/_/47e85d/32.png) [@\_sr](https://forum.getkirby.com/u/_sr)\
**Post date:** [September 28, 2023, 11:23am UTC](https://forum.getkirby.com/t/section-filters/29603/6 "2023-09-28T11:23:13Z")

</div>

A workaround would possibly be a programmable blueprint, right?

> **[Programmable blueprints](https://getkirby.com/docs/cookbook/panel/programmable-blueprints)**
>
> Create blueprints programmatically with PHP

Or should the way I tried work in theory?

---

<div class="post-metadata">

**Author:** ![dominiklaube](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/dominiklaube/32/13863_2.png) [@dominiklaube](https://forum.getkirby.com/u/dominiklaube)\
**Post date:** [February 12, 2024, 3:16pm UTC](https://forum.getkirby.com/t/section-filters/29603/7 "2024-02-12T15:16:49Z")

</div>

I had the same issue today and could only fix it with a programmable blueprint. The comparison operator `'date >='` works like expected then.

---

<div class="post-metadata">

**Author:** ![rasteiner](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rasteiner/32/4788_2.png) [@rasteiner](https://forum.getkirby.com/u/rasteiner)\
**Post date:** [February 12, 2024, 3:53pm UTC](https://forum.getkirby.com/t/section-filters/29603/8 "2024-02-12T15:53:05Z")

</div>

> [@\_sr](#):
>
> ```auto
> query: site.childrenAndDrafts.filter('dateStart', '>=', '{{ page.now }}')
> 
> ```

Two things:

1. You are passing the string `'{{ page.now }}'` to the `filter` method. The whole line already is a query, there’s no further template “substitution” happening (`'{{ page.now }}'` simply stays `'{{ page.now }}'`). You would probably want to write this as

2. if you just want to compare the date with “now”; it’s interesting to know that, in PHP, stuff like “now”, “today”, “tomorrow”, “Tuesday next week” or “first day of January this year” are actually all valid date strings. You wouldn’t therefore need a model function, it’s enough to write

---

<div class="post-metadata">

**Author:** ![dominiklaube](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/dominiklaube/32/13863_2.png) [@dominiklaube](https://forum.getkirby.com/u/dominiklaube)\
**Post date:** [February 12, 2024, 3:57pm UTC](https://forum.getkirby.com/t/section-filters/29603/9 "2024-02-12T15:57:28Z")

</div>

Thanks for the explanation. You are totally right!

---

<div class="post-metadata">

**Author:** ![\_sr](https://avatars.discourse-cdn.com/v4/letter/_/47e85d/32.png) [@\_sr](https://forum.getkirby.com/u/_sr)\
**Post date:** [February 14, 2024, 10:03am UTC](https://forum.getkirby.com/t/section-filters/29603/10 "2024-02-14T10:03:15Z")

</div>

Oh, nice! Didn’t try out `today`. That definitely works!

Thanks!
