Dynamic Structure fields

Hi there,
I would like to create a structure field to see my website.
You’d have two columns :
In the first column you would be able to see or rearrange the categories, and eventually add some more.
The second column would display the corresponding projects to that category.

When the user creates a new project, they can add a category to it, corresponding to the list in that structure field.
The strcture field will display the updated corresponding projects in the second column.

I’ve managed to far to guess it will be done using queries. But my select in my individual project (that should display the list from the first column of my structure doesn’t seem ok that I give it an array.)

fields:
  category:
    label: Category
    type: select
    options:
      type: query
      query:
        fetch: site.find('home').structure.toStructure

the query :

returns :
Kirby\Option\OptionsQuery::__construct(): Argument #1 ($query) must be of type string, array given,
Which is obvious, but how to make that work?

Your syntax is wrong here, looks like you mixed up old with new syntax. When using Kirby 3.8.x, it should be

fields:
  category:
    label: Category
    type: select
    options:
      type: query
      query: site.find('home').structure.toStructure

Alright,
thanks,
but actually, this doesn’t seem to change anything;
here is my site.yml blueprint


title: Site

sections:
  content:
    type: fields
    fields:
      structure:
        label: Structure
        type: structure
        fields:
          Action:
            label: Action
            type: text
      pages:
        label: Projets
        type: pages
        query: site.page("projets").children

If the structure field is in site.yml then trying to find the options on the home page won’t work. Change your query to … and add the text and value props:

options:
  type: query
  query: site.structure.toStructure
  text: "{{ item.action }}"
  value: "{{ item.action }}"
1 Like

Alright, I get it now, was a bit out of control.
Thanks a lot.