Modules plugin: Structure fields


What about images in modules?
At the moment i am stuck with… no images. :frowning:

EDIT: in structure field inside the module

a (image:name.jpg) gives a
<img src="http://localhost/kirbysite/name.jpg" alt="">

in the text/content field of the module image URL is ok.


EDIT: solution is within this post: Structure field with image

no kirby-text in structure… that’s sad

Kirby Modules Plugin

It is possible to use kirbytext within structure fields…? Haven’t tested within modules, though. But if it does not work, that’s probably a bug.


You should definitely be able to use Kirbytags inside structure fields. But it will only work with Modules if you use toStructure():

echo $module->myfield()->toStructure()->first()->text()->kirbytext()

Using the yaml() method won’t work as the connection to the module page is lost.


How do i loop over a structure inside module with the ->toStructure() method?

At the moment i use something like this… where the (image:) tag fails:

<?php foreach(yaml($module->columns()) as $column): ?>
 ...<?= $column['bgcolor'] ?>...
 ...<?= kirbytext($column['text']) ?>...
<?php endforeach ?>

best regards,


As you would in any other page:

<?php foreach($module->columns()->toStructure() as $column): ?>
 ...<?= $column->bgcolor() ?>...
 ...<?= $column->text()->kirbytext() ?>...
<?php endforeach ?>


the loop works well but: the (image:)-URLs are still wrong.

my temporary workaround is to put the module URL before the image name like:

(image: products/columns-sg03im/crm-box.png)


If it doesn’t work, it’s probably a bug, @lukasbestle? Or is there a workaround, like creating a new field object…?


Generally the toStructure method should take care of that stuff. I will look into it in the next few days.


Also the file-kirbytext-tag gives me wrong URL.
(file: companysecrets.pdf) -> error page
If i open the file url in browser i also get “error page/not found”… something is wrong here…hmmmm


Yes, those two issues are the same issue. The reason for both is incorrect path resolving.