Query value from site for when condition

hey everyone,

for my current project I would like to use a wuery for a when condition of a field. I couldn’t find anything about it, so I thought I just ask here.
So this is my current setup:
I have several categories that can be set on the site blueprint:

 categories:
    label: Categories
    type: structure
    fields:
      cat_name:
        label: Category name
        type: text
      cat_slug:
        label: Category identifier
        type: text
      cat_image:
        label: Category Image
        type: files
        query: page.images
        multiple: false
      is_main_cat:
        label: is an actual category
        type: toggle

I also have an event overview page with events as subpages. on those subpages I can set the category. depending from if the set category is a main category, there should be different fields on the event detail blueprint.
this would be the event detail blueprint:

     category:
        label: Category
        type: select
        options: query
        query:
          fetch: site.categories.toStructure
          text: "{{ structureItem.cat_name }}"
          value: "{{ structureItem.cat_slug }}"
      my_conditional_field:
        label: conditional field
        type: text
        when:
          site.categories.toStructure.findBy("cat_slug", "page.category.value", ",").is_main_cat: true

so I wonder if I can query the condition from the site blueprint. the query I used doesn’t work tho. :frowning:

2 Likes

It’s currently not possible to use queries in when conditions. There is a feature request on the ideas repo though.

I see. Thank you for the quick response tho!

I’d also find this very useful.
Here is the issue to vote on getkirby/ideas https://github.com/getkirby/ideas/issues/231

2 Likes

Is there any movement on this one? I’ve needed it a few times already.