Including kirbytext function when accessing structure field

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

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

Or use toStructure() instead of yaml():

<?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()

1 Like

Thank you, problem solved!