Hi there! I’m having the following problem: I have a structure field with a textarea “subfield”. The structure field is in a blueprint for a module. When I add a markdown file link for a file that’s in the module content folder, it only shows the text: that I have added to the tag but not the link. I output the textarea as YAML like so:
<?= kirbytext($box['right_text']) ?>
Thanks!
Works for me. Could you please post your complete. code snippet and the blueprint?
Here’s the blueptint:
title: Module Double Box
pages: false
files: true
fields:
title:
label: Module title
type: text
boxes:
label: Content Boxes
type: structure
fields:
left_text:
label: Text 1
type: textarea
right_text:
label: Text 2
type: textarea
direction:
label: Direction
type: checkbox
text: Reverse
…and the code I output this with:
<?php
$boxes = $module->boxes()->yaml();
foreach($boxes as $box): ?>
<div class="row<?php e($box['direction'] == 1, '-rev') ?>">
<div class="double__text ">
<div class="inner__content">
<?= kirbytext($box['left_text']) ?>
</div>
</div>
<div class="double__text ">
<div class="inner__content">
<?= kirbytext($box['right_text']) ?>
</div>
</div>
</div>
<?php endforeach ?>
Does this only happen in a module? Currently, I don’t have. a module setup to test. in.
Have. you tried with toStructure() instead of yaml()?
Ok. It wasn’t easy to find a structure field in my current project that sits directly in a regular page but I found one and tested and it works there. So, the problem appears to be with structure fields when in a module.
And no, I didn’t try a structure because I decided to abandon the plan to let the user put files for download in the textarea and instead output a, yes, structure field with a list of files for download. The issue still stands though, because it will be good to be able to place a file in a textarea in a structure in a module.
No, I meant using the toStructure() method on your structure field instead of yaml()
:
<?php
$boxes = $module->boxes()->toStructure();
foreach($boxes as $box): ?>
<div class="row<?php e($box->direction() == 1, '-rev') ?>">
<div class="double__text ">
<div class="inner__content">
<?= $box->left_text()->kt() ?>
</div>
</div>
<div class="double__text ">
<div class="inner__content">
<?= $box->right_text()->kt() ?>
</div>
</div>
</div>
<?php endforeach ?>
Yes, I understood what you meant but didn’t test it. Now I did and it works. So, to recap: no YAML in a structure field in a module. Thanks!