Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Examples: Blueprints

Bruno Meilick edited this page Oct 18, 2021 · 6 revisions

Store a single reference to a File from another Page

If you retrieve the AutoID value for Page- or File-Objects using the Method in uppercase ->AUTOID() is a little bit slower in the panel but recommended since it ensures the object is indexed. Using the lowercase version will just read the field value but is faster if you have queries with lots of results.

download:
  label: File from Download
  type: select
  options: query
  query:
    fetch: page("downloads").files
    text: "{{ file.filename }}"
    value: "{{ file.AUTOID }}" # uppercase is recommended

Store multiple references to child Pages

special:
  label: Special Child
  type: checkboxes
  options: query
  query:
    fetch: page.children.filterBy("template", "special")
    text: "{{ page.title }}"
    value: "{{ page.AUTOID }}" # uppercase is recommended

Store multiple references to StructureObjects from a different Field from another Page

Page 'a'

categories:
  label: Define Categories
  type: structure
  translate: false
  fields:
    title:
      type: text
    autoid:
      type: hidden
      translate: false

Page 'b'

category:
  label: Select Categories
  type: checkboxes
  options: query
  query:
    fetch: page('a').categories.toStructure
    text: "{{ structureItem.title }}"
    value: "{{ structureItem.autoid }}" # lowercase only for structures

TIP: This works from structures defined in the site blueprint as well (since v2.2.0).

Preview in Structure Field

To display the text in structure instead of the AutoID value you can install the Previews Plugin which will work without further configuration.

Performance

When using a lot of pages within a multiselect field you might need to add some form of caching. An example can be found in the kirby forum