# Modules plugin: Structure fields

**URL:** <https://forum.getkirby.com/t/modules-plugin-structure-fields/9430>\
**Category:** Questions\
**Tags:** v2\
**Created:** [January 23, 2017, 1:10pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430 "2017-01-23T13:10:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Svnt](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/svnt/32/620_2.png) [@Svnt](https://forum.getkirby.com/u/Svnt)\
**Post date:** [January 23, 2017, 1:10pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/1 "2017-01-23T13:10:38Z")

</div>

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

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 - #4 by texnixe](https://forum.getkirby.com/t/structure-field-with-image/1021/4)

no kirby-text in structure… that’s sad

---

<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:** [January 23, 2017, 1:39pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/2 "2017-01-23T13:39:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [January 23, 2017, 2:24pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/3 "2017-01-23T14:24:08Z")

</div>

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

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

```

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

---

<div class="post-metadata">

**Author:** ![Svnt](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/svnt/32/620_2.png) [@Svnt](https://forum.getkirby.com/u/Svnt)\
**Post date:** [January 23, 2017, 2:33pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/4 "2017-01-23T14:33:58Z")

</div>

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

---

<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:** [January 23, 2017, 2:41pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/5 "2017-01-23T14:41:42Z")

</div>

As you would in any other page:

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

```

---

<div class="post-metadata">

**Author:** ![Svnt](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/svnt/32/620_2.png) [@Svnt](https://forum.getkirby.com/u/Svnt)\
**Post date:** [January 23, 2017, 2:49pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/6 "2017-01-23T14:49:37Z")

</div>

> [@Kirby Modules Plugin (Kirby 2)](https://forum.getkirby.com/t/kirby-modules-plugin-kirby-2/4698/40):
>
> \<?= $column-\>text()-\>kirbytext() ?\>

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)`

---

<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:** [January 23, 2017, 2:52pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/7 "2017-01-23T14:52:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [January 23, 2017, 3:07pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/8 "2017-01-23T15:07:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Svnt](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/svnt/32/620_2.png) [@Svnt](https://forum.getkirby.com/u/Svnt)\
**Post date:** [January 25, 2017, 7:55pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/9 "2017-01-25T19:55:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [January 25, 2017, 8:13pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/10 "2017-01-25T20:13:06Z")

</div>

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

---

<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, 5:30pm UTC](https://forum.getkirby.com/t/modules-plugin-structure-fields/9430/11 "2025-02-06T17:30:15Z")

</div>

Archived on February 6, 2025, 5:30pm UTC


