Lets start with my intent… I’d like to have (user) configurable options for some of the pages’ fields.
For example, a select field in my “/events/event” blueprint that queries some of the /site.txt fields… which would have the configurable options I’d like to use, preferably a structure field.
This way the panel user would be able to set some options or manage values that were predefined by the developer.
A structure field in site.txt would have:
----
Site-Event-types:
-
event_code: 0
event_name: 'Meetup'
-
event_code: 1
event_name: 'Workshop'
-
event_code: 2
event_name: 'Lecture'
And the “event” blueprint could have a select field like:
event_type:
label: Type of event
type: select
options: query
query:
page: site
fetch: site_event_types[] # some way to indicate a structure field
text: '{{event_name}}'
value: '{{event_code}}'
The panel would somehow identify all the entries in the structure field, query them and allow the panel user to select one. Notice that “text:” and “value:” each brings a different “subfield” from the structure field off site.txt.
If the panel user selected the second option (Workshop) and saved… the resulting event.txt would have:
----
Event-type: 1
----
...
This way in my “event” template I’d use:
<?php
$types = $site->site_event_type()->yaml();
if( $page->event_type() == $types[1]['event_code'] ) {
//retrieve the respective entry name value from $site
echo 'Type of event: '.$types[1]['event_name'];
// prints: Type of event: Workshop
?>
Maybe there’s a way to do it… and my kirby newbieness is keeping me from seeing it… any help would be much appreciated.
Shout out to @texnixe & @distantnative if you guys could take a look please…