# Selectable child pages on pages field with query language

**URL:** <https://forum.getkirby.com/t/selectable-child-pages-on-pages-field-with-query-language/14768>\
**Category:** Questions\
**Tags:** v3\
**Created:** [June 29, 2019, 1:46pm UTC](https://forum.getkirby.com/t/selectable-child-pages-on-pages-field-with-query-language/14768 "2019-06-29T13:46:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [June 29, 2019, 1:46pm UTC](https://forum.getkirby.com/t/selectable-child-pages-on-pages-field-with-query-language/14768/1 "2019-06-29T13:46:38Z")

</div>

I want to select child pages of specific page (for ex: /pages/categories)

* * *

If i use query language, i cant select child pages (not shows “icon-angle-right”):

![FireShot%20Capture%20682%20-%20Samsung%20Galaxy%20A7%202018%2064%20GB%20(Samsung_%20-%20http___localhost_pixelshop_panel_p](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/0/0bec3de4911cfdc3c12ff68f3c4b451751597ceb.png)

**Blueprint**

```
categories:
    label: Categories
    type: pages
    multiple: true
    min: 1
    max: 5
    required: true
    options: query
    placeholder: Select Categories
    query: site.find("categories").children

```

* * *

If remove the query language, i can select but opening all pages. Second image is expected output.

![FireShot%20Capture%20680%20-%20Samsung%20Galaxy%20A7%202018%2064%20GB%20(Samsung_%20-%20http___localhost_pixelshop_panel_p](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/9/9c5449f5e6a0b82bf613ccc7270d43dbdd049b88.png)

![FireShot%20Capture%20681%20-%20Samsung%20Galaxy%20A7%202018%2064%20GB%20(Samsung_%20-%20http___localhost_pixelshop_panel_p](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/2/2aad6845076c033f647dc38ad37a3083a9e70ec9.png)

**Blueprint:**

```
categories:
    label: Categories
    type: pages
    multiple: true
    min: 1
    max: 5
    required: true
    placeholder: Select Categories

```

Is it possible with query?

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [June 29, 2019, 2:13pm UTC](https://forum.getkirby.com/t/selectable-child-pages-on-pages-field-with-query-language/14768/2 "2019-06-29T14:13:59Z")

</div>

This is about following code snippet but i didnt understand about `v-if="model"`. Query doesn’t return a model?

```
<k-button
  v-if="model"
  :disabled="!page.hasChildren"
  :tooltip="$t('open')"
  icon="angle-right"
  @click.stop="go(page)"
/>

```

[Go to line on GitHub](https://github.com/getkirby/kirby/blob/80b69380e672565a849037232c9951d1e32774c8/panel/src/components/Dialogs/PagesDialog.vue#L50)

---

<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:** [June 30, 2019, 12:14pm UTC](https://forum.getkirby.com/t/selectable-child-pages-on-pages-field-with-query-language/14768/3 "2019-06-30T12:14:41Z")

</div>

You can use `site.find("categories").index` instead of `children` to get the complete tree. The downside is that you get a flat collection, not a tree structure if you use a query.

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [June 30, 2019, 12:37pm UTC](https://forum.getkirby.com/t/selectable-child-pages-on-pages-field-with-query-language/14768/4 "2019-06-30T12:37:36Z")

</div>

Thanks. I was tried that but there are dozens categories. I need to show categories as tree. Why doesn’t working when use query? Isn’t possible that get pages as tree with query?

---

<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:** [June 30, 2019, 12:43pm UTC](https://forum.getkirby.com/t/selectable-child-pages-on-pages-field-with-query-language/14768/5 "2019-06-30T12:43:13Z")

</div>

> [@ahmetbora](#):
>
> Isn’t possible that get pages as tree with query?

Unfortunately not, but there is already an issue in the ideas repo that you might want to upvote as well\_

> <https://github.com/getkirby/ideas/issues/217>
>
> \*\*Current behavior\*\*
> 
> Let's say a custom query is used for a \`pages\` field lik…e so:
> 
> \`\`\`yaml
> related:
> title: Related pages
> type: pages
> query: site.homePage.children
> \`\`\`
> 
> The \`pages\` field will now display a list of the pages in the queried collection. Unfortunately, the full page tree is no longer displayed (because of \[this line\](https://github.com/getkirby/kirby/blob/3.0.3/config/fields/pages.php#L152)), so it's no longer possible to select subpages. Only the pages that are directly in the queried collection can be selected.
> 
> \*\*Feature idea\*\*
> 
> This may be intended for some use-cases, but in others it might make sense to select subpages as well, e.g. if you want users to select a page from a custom collection that is a filtered tree structure of pages.
> 
> \*\*Possible implementations\*\*
> 
> I think this should be a blueprint option of the \`pages\` field.
> 
> 1. Option 1: Additional blueprint option
> \`\`\`yaml
> related:
> title: Related pages
> type: pages
> query: site.homePage.children
> querySubpages: true
> \`\`\`
> 2. Option 2: Nested option
> \`\`\`yaml
> related:
> title: Related pages
> type: pages
> query:
> query: site.homePage.children
> subpages: true
> \`\`\`

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [June 30, 2019, 1:03pm UTC](https://forum.getkirby.com/t/selectable-child-pages-on-pages-field-with-query-language/14768/6 "2019-06-30T13:03:07Z")

</div>

Thank you, upvoted 👍

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [July 1, 2019, 10:04am UTC](https://forum.getkirby.com/t/selectable-child-pages-on-pages-field-with-query-language/14768/7 "2019-07-01T10:04:02Z")

</div>

Hope, i solved it:

> <https://github.com/getkirby/kirby/pull/1889>
