You can use the contents of the structure field in a template in this way:
<ul>
<? $n=0; foreach($page->related()->yaml() as $R): $n++; ?>
<?php $r = $pages->find($R['relatedarticle']); ?>
<? if($r->images() != ''): ?>
<li>
<a href="<?= $r->url() ?>" class="item<? if($n==1) echo ' active' ?>" title="<?= $r->title()->html() ?>">
<h4><?= $r->title()->html() ?></h4>
<? $image = $r->images()->first() ?>
<img src="<?= thumb($image, array('width' => 174, 'height' => 150, 'crop' => true), false) ?>" />
</a>
</li>
<? endif ?>
<? endforeach ?>
</ul>
I just changed pages
in the first line to yaml
. That will generate an array ($page->related()->yaml()
) out of the structure field contents. This array contains a list of arrays containing the fields of a structure entry. I named these arrays $R
and saved the according page to $r
.
You may use a::show($page->related()->yaml())
and a::show($R)
to see the contents of both arrays.
In the docs:
If you want to view the images in the panel it is not possible at the moment. At least not with a prebuilt field. See Using Kirby’s power in entry of structure field.