Using variable in page query

Hi everyone - I am trying to limit pages in a section in my blueprint according to a page variable but am having trouble.

To do so I am using the PagesDisplay section plugin which works with kirby’s native query language.

In the example below, ‘departments’ is the name of my multiselect field, and if I replace the variable with an option it works fine, so must be an obvious thing i’m doing syntax wise with my curlies.

    sections:
      casestudies:
        headline: '{{ page.title }} Case Studies'
        type: pagesdisplay
        query: site.index.filterBy('departments', '{{ page.title }}')
        layout: cards

Help appreciated!

have you tried site.index.filterBy('departments', page.title)?

otherwise i think the problem is that you would need to run the query resolution twice. first to resolve the {{ page.title }} then again for the outer query. but thats not what the plugin by @rasteiner is doing.

1 Like

Hi I’m so sorry for the delayed reply on this - newborn life atm! Worked perfectly thanks!

1 Like