Creating structured YAML list using panel (without keys)

Hello,

Returning to Kirby after a few years away, and there’s been quite a few changes, not least to the panel! I’m trying to create a field blueprint that allows me to add the following YAML to my document:

Routes:
- routes/london-to-chatham-and-dover
- routes/london-to-woolwich-gravesend-strood-and-rochester

However, using the structured field type, I can’t get such output. The closest I can get is an array which includes key/value pairs, i.e.:

Routes:
-
  name: routes/london-to-chatham-and-dover
-
  name: routes/london-to-woolwich-gravesend-strood-and-rochester

Below is the relevant section of my blueprint. Note also that I’m having trouble getting this to output the full UID of a page, so having to add the path manually, at this point.

fields:
  route:
    label: Route
    type: structure
    style: table
    fields:
      name:
        label: Name
        type: select
        options: query
        query:
          fetch: pages
          template: route
          value: 'routes/{{uid}}'

So, in short, using the structured field type, how can I create a simple array of page URIs (which I use in my template to create a list of related pages).

Thanks,

Paul

1 Like

Instead of using the UID, you can use the URI:

fields:
      name:
        label: Name
        type: select
        options: query
        query:
          fetch: pages
          template: route
          value: '{{uri}}'

Edit 1: Have a look at the list field. It generates the kind of output you are looking for.

Edit 2: Don’t know if you can use that together with querying pages, though. You could however adapt this field to your purposes.

Edit 3: If you can live with a comma separated list of entries, check out the multi-select field by @distantnative

Ah, of course! I forgot about the ability to get a pages URI.

Looks like I’ll need to investigate building my own field plugin, then, maybe using those that you pointed to as a starting point. Thanks!