When fetching options from a structure field in a multiselect field like documented here: Multiselect | Kirby CMS, what is the best way to access all values and use them seperately in a template?
For instance, I have a structure field on the page „Events“ with these (or more) fields:
type: fields
fields:
events:
label: Events
type: structure
fields:
eventtitle:
label: Title
type: text
eventdate:
label: Date
type: date
eventspeaker:
label: Speaker
type: text
eventtype:
label: Type
type: text
And the multiselect field on a different page (or the Editor / Builder) looks like this:
eventlist:
type: multiselect
label: Choose events to display
options: query
query:
fetch: site.find('Events').events.toStructure
text: '{{ structureItem.eventtitle }}'
value: '{{ structureItem.eventtitle }}'
And the template looks something like this:
<ul class="eventlist">
<?php foreach ($page->eventlist()->split() as $event): ?>
<li><?= $event ?></li>
<?php endforeach ?>
</ul>
Now I get a list of the selected event titles, which works fine. But whats the best way to access all values seperately? Of course I could store all values like this:
value: '{{ structureItem.eventtitle }} | {{ structureItem.eventdate }} ... '
and then Str::split them in the template, but I guess that’s not very elegant , especially with more complex values.
Thanks for help!