Get data from structure to populate info field for pages list

For page_A, I have a blueprint with some data on structure, let’s name them links:

my_list_of_URLs:
            label: Here are my URLS
            type: structure
            fields:
              myUrl:
                label: URL
                type: text
                required: true
              myTitle:
                label: Title
                type: text
              myCollection:
                label: Collection
                type: select
                required: true
                options:
                  square: SQUARE
                  fineArt: FINE ART

I then have another page, let’s call it page_B, which blueprint display a list of page A (thanks to PagesDisplay Section plugin).
So this list contains element of type page A.
I then want to display additional data for each item extracted from the previous my_list_of_URLs structure.

my_list_strange_stuff:
            headline: some Page_A stuff
            type: pagesdisplay
            query: site.find("page_A").children.children.filterBy("okHouston",true)
            controls: false
          
            info: " {{ page.my_list_of_URLs.toStructure... }}"
            limit: 10

And I don’t know what to to next. The exact need is to display as info all myCollection defines for page_A.
In other words, how can I retrieve the list of myCollection data contained in all elements from the structure?

So what is missing is this portion of code:
info: " {{ page.my_list_of_URLs.toStructure *** THE MISSING PART *** }}"

A picture is better than thousand words so here is one:

So for the first line, painting 2018-005, structure looks like:

myUrl myTitle myCollection
11111111 square poster on black square
222222 high quality print fineArt

For that you need a custom page method/model method that returns the values you need as comma separated list.

e.g. method getMyCollectionList() would return

implode(', ', $page->my_list_ofURLs()->toStructure()->pluck('myCollection', ',', true))

Hi,

Thank you ! I created a model in this case. It works fine!
Again: a great than you!

I wish you a beautiful and lightfull day!
:grinning: :sun_with_face:

1 Like