I am upgrading one of our sites from Kirby 2 to Kirby 3 and are having a problem with a foreach loop in one of my snippets.
The code below is a snippet for a gallery that is part of a one-pager.
For some reason <?= $project_image->url() ?> inside the foreach loop breaks the page.
Outside the loop the url prints just fine.
I have used similar code in my other snippets, and there it works just fine. It just doesn’t work in this one particular snippet.
In addition the site reports no php errors which makes it incredible hard to debug. I am not sure if this is because of some interaction between Kirby and the php error log I am not aware of. But have tried added error reporting in both php and apache.
Really stuck here, and any help would be much appreciated.
<div id="projects" class="section" >
<div class="sectioncontent">
<h1><?= $data->title()->html() ?></h1>
<div class="projectgallery">
<?php foreach($data->children()->listed() as $project): ?>
<?php // Convert the filename to a full file object
$project_image = $project->projectimage()->toFile(); ?>
<a href="<?php echo $project->url() ?>">
<div class="projectThumb" style='background-image: url(<?= $project_image->url() ?>)'>
<div class="projectInfo">
<h1><?php echo $project->title()->html() ?></h1>
<p><?php echo $project->clientName()->html() ?></p>
<div class="ProjectText">
<?php echo $project->summary()->kirbytext() ?>
</div>
</div>
<div class="projectThumbOverlay">
</div>
</div>
</a>
<?php endforeach ?>
</div>