# Including kirbytext function when accessing structure field

**URL:** <https://forum.getkirby.com/t/including-kirbytext-function-when-accessing-structure-field/7680>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 7, 2017, 11:09am UTC](https://forum.getkirby.com/t/including-kirbytext-function-when-accessing-structure-field/7680 "2017-06-07T11:09:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davabo](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davabo](https://forum.getkirby.com/u/davabo)\
**Post date:** [June 7, 2017, 11:09am UTC](https://forum.getkirby.com/t/including-kirbytext-function-when-accessing-structure-field/7680/1 "2017-06-07T11:09:38Z")

</div>

Hi guys,

Hopefully a simple question here.

Im accessing my structure field like this:

```
Blueprint:
  roomimage: 
    label: Image/Title Section
    type: structure
    entry: >
      <b>Image</b>:</br>
      <img src="{{image}}" style="width:200px;height:200px;" />
      </br>
      </br>
      <b>Title</b>:</br>{{title}}
      </br>
      </br>
      <b>Text</b>:</br>{{textblock}}
      </br>
    fields: 
      image:
        label: Image
        type: select
        options: query
        query:
          fetch: files
          value: '{{url}}'
          text: '{{filename}}'
      title:
        label: Title
        type: text
      textblock:
        label: Room Text Block
        type: textarea

```

PHP

```
<?php $test = yaml($page->roomimage()) ?>
<?php foreach($test as $t): ?>
  <?php echo $t['textblock'] ?>
<?php endforeach; ?>

```

Im trying to add the kirbytext function onto the end of $[‘textblock’, ie: \<?php echo $t['textblock']-\>kirbytext() ?\>  
But it throws back an error, is there any way to add the kirbytext function so it recognises panel spaces?

Cheers

---

<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 7, 2017, 11:14am UTC](https://forum.getkirby.com/t/including-kirbytext-function-when-accessing-structure-field/7680/2 "2017-06-07T11:14:53Z")

</div>

> [@davabo](#):
>
> \<?php echo $t[‘textblock’] ?\>

```auto
<?php echo kirbytext($t['textblock']) ?>

```

Or use `toStructure()` instead of `yaml()`:

```auto
<?php $test = $page->roomimage()->toStructure(); ?>
<?php foreach($test as $t): ?>
  <?php echo $t->textblock()->kt() ?>
<?php endforeach; ?>

```

`toStructure()` returns a Collection object and is much more versatile, and I’d recommend using that method if you don’t have a particular reason to use `yaml()`

---

<div class="post-metadata">

**Author:** ![davabo](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davabo](https://forum.getkirby.com/u/davabo)\
**Post date:** [June 7, 2017, 11:16am UTC](https://forum.getkirby.com/t/including-kirbytext-function-when-accessing-structure-field/7680/3 "2017-06-07T11:16:37Z")

</div>

> [@texnixe](#):
>
> \<?php echo kirbytext($t[‘textblock’]) ?\>

Thank you, problem solved!

---

<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:49pm UTC](https://forum.getkirby.com/t/including-kirbytext-function-when-accessing-structure-field/7680/4 "2025-02-06T16:49:48Z")

</div>


