I have a structure field “Package Groups” all data loads except the image only getting the first image path repeated for each item in the loop. Any suggestions greatly received.
<?php foreach ($page->packagegroups()->toStructure() as $value): ?>
<li>
<?php if($image = $value->cardimage()): ?>
<img src="<?= $value->cardimage()->toFiles() ?>" alt="">
<?php endif ?>
<!-- Out puts path to one of the three images not looping and loading each of the three images -->
<?= $value->cardimage()->toFiles() ?>
<h2><?= $value->cardheading()->escape() ?></h2>
<?= $value->cardtext()->kt() ?>
<a href="<?= $link = $value->cardpagelink()->toLinkObject();?>" class="p_button--primary"><?= $value->cardlink() ?></a>
</li>
<?php endforeach ?>
Blueprint:
fields:
packagegroups:
label: Package Groups
type: structure
fields:
cardimage:
type: files
layout: cards
cardheading:
label: Card Heading
type: text
cardtext:
label: Card Text
type: text
cardlink:
label: Card Link Text
type: text
cardpagelink:
label: Card Page Link
type: link
width: 1/2
linkTypes:
- page