Use array of structure field entries in blueprint query language

Hi everyone,

I have pages to store bibliographic data of books etc. On each page there is a structure field to add multiple authors.

I now want to show these authors in the info text of a pages section. I was thinink about something like page.authors.toStructure.pluck('lastname') but I am not sure is this is possible at all.

Thank you a lot for your help!

pluck() returns an array, but you need a string. Should be possible with a custom method that returns a string, though.

Thank you!
Could you give me a hint how to get started with a custom method?

Sure, there’s an entire section in the docs dedicated to that:

As a beginner I am not sure, if this is perfect, but it works so far.

  'implode' => function ($structureField, $key) {
    $array = $this->$structureField()->toStructure()->pluck($key);
    return implode(" / ", $array);

I will add if statements to check for the fields.

Any comments for improvement are appreciated!