# Selecting listed pages

**URL:** <https://forum.getkirby.com/t/selecting-listed-pages/25890>\
**Category:** Questions\
**Tags:** v3\
**Created:** [July 2, 2022, 2:09pm UTC](https://forum.getkirby.com/t/selecting-listed-pages/25890 "2022-07-02T14:09:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![denkstream](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/denkstream/32/6628_2.png) [@denkstream](https://forum.getkirby.com/u/denkstream)\
**Post date:** [July 2, 2022, 2:09pm UTC](https://forum.getkirby.com/t/selecting-listed-pages/25890/1 "2022-07-02T14:09:21Z")

</div>

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? 🙈 )

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [July 2, 2022, 3:07pm UTC](https://forum.getkirby.com/t/selecting-listed-pages/25890/2 "2022-07-02T15:07:19Z")

</div>

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](https://getkirby.com/docs/reference/panel/fields/files#how-to-use-in-templates-snippets__single-file)

---

<div class="post-metadata">

**Author:** ![Oli1](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/oli1/32/14419_2.png) [@Oli1](https://forum.getkirby.com/u/Oli1)\
**Post date:** [July 8, 2022, 10:01am UTC](https://forum.getkirby.com/t/selecting-listed-pages/25890/3 "2022-07-08T10:01:08Z")

</div>

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.

 ![Bildschirmfoto 2022-07-08 um 11.56.16](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/f/f7fe69e8b12183cadc6f61f58ab81f75be3e9352.jpeg)

```auto
  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

```
