I have a page X that has multiple sub-pages. I want to loop through those subpages and display content from each sub-page on page X. But, I’m unable to and I’m not getting any errors. Here is my PHP code –
<?php $pastdeals = $page->deals()->toPages() ?>
<?php foreach ($pastdeals as $pastdeal): ?>
<div>
<img src="<?= $pastdeal->image()->toFile()->url() ?>">
<span>
<p>Location: <?= $pastdeal->location() ?></p>
<p>Built-Up Area: <?= $pastdeal->builtuparea() ?></p>
</span>
</div>
<?php endforeach ?>
Here is the blueprint for page X –
sections:
content:
type: fields
fields:
description:
label: Past Deals Description
type: textarea
deals:
type: pages
Here is the blueprint for the sub-pages –
sections:
content:
type: fields
fields:
image:
label: Picture
type: files
max: 1
location:
label: Location
type: text
builtuparea:
label: Built-Up Area
type: text