How to auto prefill structure field in panel page

Need to create read only table in panel page which has pre-filled data of certain pages which has certain tag.

So were thinking about creating structure field, but stuck on problem, that as it seems for structure fields there are no possibility to query and pre-fill. Is it so?

Practical example - has building.yml with tags field:

architects:
    label: Architects
    type: tags
    options: query
    accept: options
    query:
      fetch: site.index.template("architect")
      text: "{{ page.title }}"
      value: "{{ page.title }}"

and now in architects.yml I need opposite way - filter out and show data (in structure field?) of building.yml pages where particular architect as tag is added…

Any advice and guidance would be very helpful.

You could probably do this via a hook, although I’m not sure if you can update the field if it is disabled in the blueprint. Why do you need to display this information in the Panel?

As client adds new Architect, he wants to see in its panel page which buildings it has created… kind of overview.
(Its part of migration to Kirby and this feature was in previous SQL based admin panel).

It means, that hook should check and update information (which Building pages Architect has) every time when someone opens particular Architect panel page… Which hook would it be?

No, a page.update:after hook would have to run whenever one of the building.yml files is updated (and a new tag added/removed).

The maybe better alternative would be to use an info field that queries the information and displays it as a list/table. Then you wouldn’t need the hook. You could create a page method/page model method that returns such a list.

Did not thought that its possible to put inside of info field a table… Will try. Thank You @texnixe !

I’d call a snippet inside the custom method to keep the code clean.

Seems that found some solution:

    fields:
      buildings:
        label: Architects related buildings
        type: pages
        query: site.index.template("buildings").children

Only problem, that those pages are not visible right away - I need to select filtered pages manually via “+add”… is there solution to select them automatically?

Oh, I thought you wanted to display a table with info. If you just want the pages listed, then use the pagesdisplay plugin instead of a pages field:

1 Like

Thank You @texnixe (few minutes earlier also found that same plugin - implemented - its working as expected!)

Info block with some specific information about related pages would be preferred, but Im fine with related pages list.