I’m having some trouble looping through a nested structure. I can display the content of the firs one, Months, but I’m not able to loop through the items in each month.
HTML Structure
<div class="box-schedule">
<div class="grab-scroll-tb">
<?php $months = $page->listingStructure()->toStructure();
foreach ($months as $month): ?>
<div class="schedule-month current">
<div class="schedule-header">
<h3 class=""><?= $month->months() ?> <span class="title-year hide-desktop">2022</span></h3>
</div>
<?php $listing = $month->eventStructure()->toStructure();
foreach ($listing as $item): ?>
<div class="schedule-event">
<a href="#" aria-label="description" target="_blank">
<h4 class=""><?= $item->locationName() ?></h4>
<span class="event-city"><?= $item->locationCity() ?>, <?= $item->locationCountry() ?></span>
<div class="event-date lg">
<span><?= $item->startDate()->toDate('l-d-F') ?></span>
<span><?= $item->startTime()->toDate('hh:mm') ?> - <?= $item->endTime()->toDate('hh:mm') ?></span>
</div>
</a>
</div>
<?php endforeach ?>
</div>
<?php endforeach ?>
</div><!-- end grab-scroll-tb -->
</div><!-- box-schedule -->
Blueprint:
listingStructure:
label: Listings
type: structure
fields:
months:
label: Month
type: text
eventStructure:
label: Shows
type: structure
fields:
locationName:
label: Location Name
type: text
locationCity:
label: Location City
type: text
width: 1/2
locationCountry:
label: Location Country
type: text
width: 1/2
startDate:
label: Stard Date
type: date
width: 1/2
endDate:
label: End Date
type: date
width: 1/2
startTime:
label: Start Time
type: time
width: 1/2
endTime:
label: End Time
type: time
width: 1/2