# Pages select option with full path

**URL:** <https://forum.getkirby.com/t/pages-select-option-with-full-path/3542>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 8, 2016, 10:12pm UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542 "2016-03-08T22:12:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lomacar](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lomacar/32/1553_2.png) [@Lomacar](https://forum.getkirby.com/u/Lomacar)\
**Post date:** [March 8, 2016, 10:12pm UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542/1 "2016-03-08T22:12:28Z")

</div>

I want to have a “related pages” feature on some pages on my site. I figured out how to get the blueprint working so I can select pages, however they just store the page (end folder) name, not the full path. How can I store the full path so that in the template I can link to those exact pages?

This is the related pages section of the blueprint I have:

```
  related:
    label: Related Pages
    type: structure
    style: table
    fields:
      page:
        label: Page
        type: select
        options: pages
            
      description:
        label: Page Description
        type: text

```

---

<div class="post-metadata">

**Author:** ![AugustMiller](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/augustmiller/32/160_2.png) [@AugustMiller](https://forum.getkirby.com/u/AugustMiller)\
**Post date:** [March 8, 2016, 10:24pm UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542/2 "2016-03-08T22:24:39Z")

</div>

Take a look at the Select menu’s [`query` options](https://getkirby.com/docs/cheatsheet/panel-fields/select).

I think you’re looking for the `uri` argument for the `value` option.

Your blueprint would look like this:

```auto
  related:
    label: Related Pages
    type: structure
    style: table
    fields:
      page:
        label: Page
        type: select
        options: pages
        value: '{{uri}}'

```

Basically, for each of the `pages` in the menu, the `value` attribute on the `option` element is set to the returned value of its `uri` method:

```php
$page->uri(); # path/to/page-slug

```

You can use the `toPage()` [field method](https://getkirby.com/docs/cheatsheet/field-methods/toPage) to transform your field’s value into a complete page object:

```auto
<ul>
  <? foreach ( $page->related()->toStructure() as $related_item ) { ?>
    <li><?= $related_item->page()->toPage()->title() ?></li>
  <? } ?>
</ul>

```

---

<div class="post-metadata">

**Author:** ![Lomacar](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lomacar/32/1553_2.png) [@Lomacar](https://forum.getkirby.com/u/Lomacar)\
**Post date:** [March 8, 2016, 10:33pm UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542/3 "2016-03-08T22:33:20Z")

</div>

It doesn’t look like the query features of “value” or “text” or anything work in combination with `options: pages`. And `options: query` asks for another page to query from, but I don’t want to query from a single page, I want to query the whole site for the list of all pages, or actually, better yet I want to get the list of all pages and subpages within a certain section of the site.

But thanks for the template code. That will come in handy.

---

<div class="post-metadata">

**Author:** ![AugustMiller](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/augustmiller/32/160_2.png) [@AugustMiller](https://forum.getkirby.com/u/AugustMiller)\
**Post date:** [March 8, 2016, 10:40pm UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542/4 "2016-03-08T22:40:55Z")

</div>

You can combine the `page` and `fetch` options to get an index of your entire site:

```auto
related:
  label: Related Pages
  type: structure
  style: table
  fields:
    page:
      label: Page
      type: select
      options: query
      query:
        page: /
        fetch: index
        value: '{{uri}}'

```

This is undocumented, but it appears to work just fine…

If you want to get, say, related pages in a specific page tree beneath a top-level page, you can use that page’s slug as the `page` value within the `query` options.

---

<div class="post-metadata">

**Author:** ![Lomacar](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lomacar/32/1553_2.png) [@Lomacar](https://forum.getkirby.com/u/Lomacar)\
**Post date:** [March 8, 2016, 10:46pm UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542/5 "2016-03-08T22:46:13Z")

</div>

Nice it works! Thanks.

---

<div class="post-metadata">

**Author:** ![max](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/max/32/129_2.png) [@max](https://forum.getkirby.com/u/max)\
**Post date:** [June 20, 2016, 3:47am UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542/6 "2016-06-20T03:47:04Z")

</div>

The [page input](https://getkirby.com/docs/cheatsheet/panel-fields/page) is also an option here. It references all pages and outputs the uri by default.

However the select input offers more customization and seems to work better in the structure field modal.

---

<div class="post-metadata">

**Author:** ![nanimo](https://avatars.discourse-cdn.com/v4/letter/n/ea666f/32.png) [@nanimo](https://forum.getkirby.com/u/nanimo)\
**Post date:** [January 10, 2018, 9:49am UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542/7 "2018-01-10T09:49:20Z")

</div>

Thanks for your help. Much appreciated, as I am new to Kirby.

One note though. If I’m not mistaken, the last line

> value: ‘{{uri}}’

should be indented further. It should be on the same level as

> fetch: index

---

<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:** [January 10, 2018, 10:13am UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542/8 "2018-01-10T10:13:40Z")

</div>

Thanks for the hint, I have corrected it.

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:30pm UTC](https://forum.getkirby.com/t/pages-select-option-with-full-path/3542/9 "2025-02-06T17:30:13Z")

</div>


