Hi there. I’m using a structure field to collect a small number of events for an event calendar (no more than 20 events per year). I wanted to know if you good folks can give me a boost with how to set this up. I have the structure field all set and I have a calendar all set (thanks to Bastain’s wondrous calendar library), but I’m stuck on how to determine if an event exists in the structure field based on the date generated within the foreach loop. Do I have to search the whole structure field collection each time the foreach loop iterates?
You mean you have a date and need to find all events on that date? You can filter the structure collection by date just like any other collection:
<?php
$date = strtotime('2016-10-01');
$events = $page->events()->toStructure();
$eventsByDate = $events->filterBy('date', '==', $date);
Thank you greatly. Gotta read through these docs in more detail.