# Access values of query in structure field

**URL:** <https://forum.getkirby.com/t/access-values-of-query-in-structure-field/12348>\
**Category:** Questions\
**Tags:** v2\
**Created:** [January 22, 2019, 12:28pm UTC](https://forum.getkirby.com/t/access-values-of-query-in-structure-field/12348 "2019-01-22T12:28:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mafleig](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mafleig/32/15806_2.png) [@mafleig](https://forum.getkirby.com/u/mafleig)\
**Post date:** [January 22, 2019, 12:28pm UTC](https://forum.getkirby.com/t/access-values-of-query-in-structure-field/12348/1 "2019-01-22T12:28:13Z")

</div>

How can i display a value of query in structure field?

My blueprint looks like this:

```
 sammlung:
label: sammlung
type: structure
fields:
  bild:
    label: Bild
    type: select
    required: true
    options: query
    query:
      page: bibliothek/werke
      fetch: children
      value: '{{title}} {{image}}'
      text: '{{title}}'

```

My code like this:

```
  <?php foreach ($page->sammlung()->toStructure() as $bild): ?>

  <li class="showcase-item column">

    <a href="<?= $bild->image()->url() ?>" >

          <img class="immy" src="<?= $thumb->url() ?>"/>

        <div class="buname">
          <?= $bild->title()->html() ?>
        </div>
        <div class="bu">
          <?= ($p = $bild->kuenstler()->toPage())? $p->title(): ''?>
        </div>

    </a>

  </li>

<?php endforeach ?>

```

---

<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 22, 2019, 1:11pm UTC](https://forum.getkirby.com/t/access-values-of-query-in-structure-field/12348/2 "2019-01-22T13:11:54Z")

</div>

You should store the URI of the page in the field, not the title and image. `Value` is what get’s stored in the content file, `text` what is shown to the user. With your current storage value, `toPage()` will not find a page.

Also, I don’t see a field called `kuenstler` in your structure field? So it should be `$bild->bild()->toPage()` after you have fixed your value.

---

<div class="post-metadata">

**Author:** ![mafleig](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mafleig/32/15806_2.png) [@mafleig](https://forum.getkirby.com/u/mafleig)\
**Post date:** [January 22, 2019, 1:36pm UTC](https://forum.getkirby.com/t/access-values-of-query-in-structure-field/12348/3 "2019-01-22T13:36:55Z")

</div>

Ah, thanks! Now i got 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:22pm UTC](https://forum.getkirby.com/t/access-values-of-query-in-structure-field/12348/4 "2025-02-06T17:22:50Z")

</div>


