Hi,
I’m sorry, i’m trying to learn PHP but i’m stumped with this…
On a website homepage I want to ‘pull’ information from the “Services” section of the website. After trying multiple variations of code I thought might work I have given up and come here for help
The url, title and IntroParagraph from the Services ‘pages’ are showing as expected but I cannot get the image to display! The blueprint field name is ‘MainHeroImage’
H have the following in my homepage template:
<?php foreach ($pages->find('services')->children()->listed() as $item): ?>
<li class="home-service-card">
<a href="<?= $item->url() ?>">
<h2><?= $item->title() ?></h2>
<p><?= $item->IntroParagraph() ?></p>
<?php if ($image = $item->MainHeroImage()->toFile()): ?>
<div class="img">
<img src="<?= $image->url() ?>" alt="">
</div>
<?php endif ?>
</a>
</li>
<?php endforeach ?>
Thanks for any advice