Showing values in one panel structure field from another panel structure field

Hey everybody,
I am trying to wrap my head around if it is possible to show values in a structure field that come from another structure field as text.
The scenario is as follows:
In my project I have a list of clients. This is structure 1. Each client has an account Manager responsible. The manager comes from the page managers and ist selected via a query.
The page managers has the list of managers. I want to show besides each manager which client they are responsible for, since they can be responsible for multiple clients.
I have the following blueprints set up:
On site.yml:

clients:
  type: structure
  label: Clients
  fields:
    client:
      label: Client Name
      type: text
    manager:
      label: Account Manager
      type: select
      options: query
      query:
        fetch: site.find("managers").managers.sortBy("name","asc").toStructure
        text: "{{ structureItem.name }}"
        value: "{{ structureItem.name }}"

and on managers.yml:

managers:
    label: Account Managers
    type: structure
    style: table
    sortBy: name
    fields:
      name:
        label: Name 
        type: text
        width: 1/4
      email:
        label: Email
        type: text
        width: 1/3
      clients:
        label: Assigned Clients
        type: info
        text: >
          {{ site.clients.toStructure
              .filterBy("manager", item.name)
              .pluck("client")
              .join(", ")
          }}

All I get is all of the clients, without filtering and the rest.
Is that even possible?

Thanks a lot for your help!
Memi

I’m not sure if this reference exits at this point, probably not

hi @texnixe
Thanks for your feedback, it does not look like it. Nor does structureItem.name.
Is there a reference to the item of the structure?

An alternative solution is to populate the clients field via a hook when the site content is changed.
I guess I’ll resort to that.

No, that’s what I meant, you don’t have access to the current item in the structure field, no matter if you call it item, structureItem or whatever.

By the way, no matter if you have a structure or a array here, these items can now be referenced simply as item.name etc., structureItem is what we had in previous versions, so I’d change this in case the old syntax will be removed in the future.

1 Like