Hello,
On the home page, for each other page with the template location I am trying to display images merged from a particular field on that page, with images from any image block of its children pages.
I know that the code below is not going to do what I want because of the foreach
loops, and that is where I start to get lost, extracting each image from each block of each child page.
<?php
$locations = site()->index()->filterBy('intendedTemplate', 'location')->listed();
foreach ($locations as $location): ?>
<div>
<?php
$coll = new Collection();
$locationImages = $location->siteImages()->toFiles();
$responses = $location->children()->listed();
foreach ($responses as $response) {
$responseBlocks = $response->responseContent()->toBlocks()->filterBy('type','image');
foreach ($responseBlocks as $responseBlock) {
$responseImage = $responseBlock->image()->toFile();
}
};
$coll = $coll->add($locationImages)->add($responseImage);
?>
</div>
<?php endforeach ?>
Any help would be appreciated.