This is a select field for Kirby that pulls it's options from a specified structure field found on any page of the website. Credit to Sonja for the intial version, I just made it a little more awesome and packaged it as a plugin.
Clone or download this repo, and rename the folder to select-a-structure
. Move it into your site/plugins
folder (if that folder doesn't exist, create it).
If you are using the Kirby CLI, you can install it using this command:
kirby plugin:install CalebGrove/select-a-structure
First, create your structure field anywhere on the website and populate it.
Then, put this into your blueprint where you want the select field to appear:
fieldname:
label: Field Label
type: selectastructure
structurepage: staffpage
structurefield: stafflist
optionkey: staffname
You'll want to change these required options:
structurepage:
page/subpage
. The current page can by selected by leaving this blank. To point to the site()
page, use /
structurefield:
structurepage
.optionkey:
Use in your templates just like any select field. The data stored by the field exactly matches the text shown in the options.
And you're ready to rock and roll!