# Get URI from Select field

**URL:** <https://forum.getkirby.com/t/get-uri-from-select-field/1349>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 15, 2015, 5:53pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349 "2015-06-15T17:53:51Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![joslemmons](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/joslemmons/32/385_2.png) [@joslemmons](https://forum.getkirby.com/u/joslemmons)\
**Post date:** [June 15, 2015, 5:53pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/1 "2015-06-15T17:53:51Z")

</div>

This seems really obvious, but I cannot get it to work for me. Basically, I want the user to select a child page from the Select box in the panel, and from there, I want to use that Page to echo out the title, etc.

But I can’t get the page called in my code. ‘Home’ is the parent page, ‘category()’ is the child page name from the select dropdown in the panel.

```html
<?php $feature = $pages->find('home')->category(); ?>

<h1><?php echo $feature->title()->html() ?></h1>
<h3><?php echo $feature->date('l, F j, Y') ?></h3>
<p><?php echo $feature->text()->kirbytext()->excerpt('400') ?></p>

```

Thanks so much for any help!

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [June 15, 2015, 6:26pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/2 "2015-06-15T18:26:19Z")

</div>

In the first line you are fetching the homepage’s `category` field itself. On its own it has no relation to the page object you are trying to access (it is simply the string you entered into the field).

If the pages are placed on the top-level, you can access them using the following:

```php
$category = (string)$pages->find('home')->category();
$feature = $pages->find($category);

```

Otherwise you will need to prefix the second line with the parent page:

```php
$feature = $pages->find('parent/' . $category);

```

---

<div class="post-metadata">

**Author:** ![joslemmons](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/joslemmons/32/385_2.png) [@joslemmons](https://forum.getkirby.com/u/joslemmons)\
**Post date:** [June 15, 2015, 6:47pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/3 "2015-06-15T18:47:12Z")

</div>

Thanks for your reply @lukasbestle, but this didn’t work either.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [June 15, 2015, 7:30pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/4 "2015-06-15T19:30:54Z")

</div>

What exactly didn’t work? Unfortunately, my crystal ball is being repaired right now. 😃

---

<div class="post-metadata">

**Author:** ![joslemmons](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/joslemmons/32/385_2.png) [@joslemmons](https://forum.getkirby.com/u/joslemmons)\
**Post date:** [June 15, 2015, 7:48pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/5 "2015-06-15T19:48:16Z")

</div>

lol, Sorry for the vagueness… 😶

So it looks like that is still not outputting anything. I tried both versions you mentioned, just in case – and neither one seems to be converting that text from the Select field into a usable Page for the echos below it.

The rest of the page below that bit of code does not load. So it’s breaking there. And thanks for your help!

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [June 15, 2015, 8:19pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/6 "2015-06-15T20:19:27Z")

</div>

What happens if you insert a `var_dump($category)` right after the first line?

---

<div class="post-metadata">

**Author:** ![joslemmons](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/joslemmons/32/385_2.png) [@joslemmons](https://forum.getkirby.com/u/joslemmons)\
**Post date:** [June 15, 2015, 8:25pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/7 "2015-06-15T20:25:27Z")

</div>

That produced:

```
string(9)"EventName"

```

“EventName” being the title of the page I’m trying to call items from.

---

<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 15, 2015, 8:57pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/8 "2015-06-15T20:57:48Z")

</div>

If Eventname is the title, then it obviously isn’t the uri you are trying to get here. Could you post your blueprint?

---

<div class="post-metadata">

**Author:** ![joslemmons](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/joslemmons/32/385_2.png) [@joslemmons](https://forum.getkirby.com/u/joslemmons)\
**Post date:** [June 15, 2015, 9:17pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/9 "2015-06-15T21:17:37Z")

</div>

Absolutely, here you go! It’s a mostly static home page, with an intro blurb and a featured event.

```
title: Home

pages: false

fields:
	title:
		label: Title
		type: text
	intro:
		label: Introduction
		type: markdown
	category:
		label: Featured Event
		type: select
		options: query
		query:
			page: events
			fetch: children

```

Like I mentioned earlier, I would like the user to select the event to be featured from a Select dropdown. I thought that as long as it was outputting the name of the event page, I could easily pull that “category” (ex. EventName) and get my event page title, date, description, etc. from there. But that has not happened.

Thank you guys!

---

<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 15, 2015, 9:32pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/10 "2015-06-15T21:32:29Z")

</div>

I guess one of the two solutions below should work:

```php
$featuredEvent = $site->index()->findBy('uid', $category);

```

or

```php
$featuredEvent = page('events')->children()->findBy('uid', $category);

```

I still wonder why $category outputs the title, the default is the uid …

---

<div class="post-metadata">

**Author:** ![joslemmons](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/joslemmons/32/385_2.png) [@joslemmons](https://forum.getkirby.com/u/joslemmons)\
**Post date:** [June 15, 2015, 9:39pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/11 "2015-06-15T21:39:52Z")

</div>

@texnixe – That second one got it!! Thank you so much, I really appreciate it.  
And reading your solution makes sense… I just couldn’t get there myself!

---

<div class="post-metadata">

**Author:** ![bgamm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bgamm/32/2727_2.png) [@bgamm](https://forum.getkirby.com/u/bgamm)\
**Post date:** [August 26, 2016, 8:30pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/12 "2016-08-26T20:30:24Z")

</div>

Having the same issue — using a select dropdown in the panel to choose from a list of venues for an event. Here’s my implementation of the suggested solution:

Event snippet:

```auto
<?php $featVenue = page('venues')->children()->findBy('uid', $venue); ?>

<p>Venue: <a href="<?php echo $featVenue->url() ?>">
  <?php echo $featVenue->title() ?>    
  </a>
</p>

```

Event blueprint:

```auto
venue:
    label: Venue
    type: select
    options: query
    query:
      page: venues
      fetch: visibleChildren

```

Just to clarify, when I add a venue from the dropdown in the Panel, only the bare page uid is returned. So for example, if the venue title was `Coffee Shop`, it gets saved in the markdown file as `venue: coffee-shop`.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [August 27, 2016, 11:35am UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/13 "2016-08-27T11:35:10Z")

</div>

What exactly doesn’t work for you? And how do you get the `$venue` variable?

---

<div class="post-metadata">

**Author:** ![Thiousi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thiousi/32/13656_2.png) [@Thiousi](https://forum.getkirby.com/u/Thiousi)\
**Post date:** [August 27, 2016, 11:59am UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/14 "2016-08-27T11:59:16Z")

</div>

Spoiler alert!

It looks like it should be $page-\>venue() instead of $venue

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [August 27, 2016, 12:32pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/15 "2016-08-27T12:32:26Z")

</div>

Well, that’s why I asked how he got the variable. 🙂

---

<div class="post-metadata">

**Author:** ![bgamm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bgamm/32/2727_2.png) [@bgamm](https://forum.getkirby.com/u/bgamm)\
**Post date:** [August 27, 2016, 8:46pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/16 "2016-08-27T20:46:16Z")

</div>

@Thiousi @lukasbestle YES! That’s it! Probably spent two hours trying every syntax combo I could think of… thanks again 😅

---

<div class="post-metadata">

**Author:** ![Thiousi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thiousi/32/13656_2.png) [@Thiousi](https://forum.getkirby.com/u/Thiousi)\
**Post date:** [August 27, 2016, 8:48pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/17 "2016-08-27T20:48:17Z")

</div>

Sometimes you’re just with your head so focused on the code that you don’t even see the obvious just in front of you 🙂

Glad we could help!

---

<div class="post-metadata">

**Author:** ![bgamm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bgamm/32/2727_2.png) [@bgamm](https://forum.getkirby.com/u/bgamm)\
**Post date:** [August 27, 2016, 8:50pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/18 "2016-08-27T20:50:00Z")

</div>

A little bit of that, and a lot of: ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/2/2416405c2b3c3d40f4ef22ecff49f1a0ccf3ebc3.jpg)

---

<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, 4:53pm UTC](https://forum.getkirby.com/t/get-uri-from-select-field/1349/19 "2025-02-06T16:53:15Z")

</div>


