Selecting listed pages

Hey everyone (again),

I’m currently building custom block types, I would like to add a simple button, but with an option in blueprint to select internal, listed pages to be linked. Now the blueprint part for that custom block looks like this:

button:
  name: Button mit interner Verlinkung
  icon: bolt
  label: "{{ text }}"
  fields:
    link:
      label: Bitte wählen Sie eine Seite
      type: select
      query: site.pages.published
      ...
    text:
      type: text

Unfortunately I’m not the brightest about php and querying, the query above shows only first level pages published but not the all, second would be that a “linkable” format to echo it in the template? (probably not? :see_no_evil: )

  1. Since there is a pages field, I’d use that instead of a select
  2. If you want to query all pages over your whole site, use site.index.published
  3. In your template, you can output the link to the page like described in the docs: Files | Kirby CMS

Do you mean something like that? Then it makes the most sense to work with the when condition in the Blueprints. As Sonja already mentioned, a Pages field makes the most sense for the pages.

  linkbuilder_type:
    type: select
    label: Linktyp
    width: 1/3
    default: linkbuilder_type_page
    options:
     linkbuilder_type_page: Seite
     linkbuilder_type_url: Eigene URL
     linkbuilder_type_file: Eigene Datei

  linkbuilder_type_page:
    type: pages
    label: Interne Seite
    multiple: false
    width: 2/3
    empty: "Bitte eine Seite auswählen"
    when:
      linkbuilder_type: linkbuilder_type_page

  linkbuilder_type_url:
    type: text
    label: Eigene URL
    before: "URL"
    icon: url
    width: 2/3
    when:
      linkbuilder_type: linkbuilder_type_url

  linkbuilder_type_file:
    type: files
    label: Datei
    multiple: false
    width: 2/3
    empty: "Bitte eine Datei auswählen"
    when:
      linkbuilder_type: linkbuilder_type_file