Modules plugin: Structure fields


#1

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.

Why?

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

no kirby-text in structure… that’s sad


Kirby Modules Plugin
#2

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.


#3

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.


#4

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,
Sven


#5

As you would in any other page:

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

#6

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)


#7

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


#8

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


#9

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


#10

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