Hello, I have a question about a very common pattern but I still haven’t managed to figure it out.
I have an Events page in which I’m filtering the current events so the template looks like this:
<h1>Current Events</h1>
<?php
$events = page('events')->events()->toStructure()->filter(function($child) {
return $child->date(null, 'startdate') < time() && $child->date(null, 'enddate') > time();
});
foreach($events as $event): ?>
<div class="event">
…
</div>
<?php endforeach ?>
But if there is no current event, the title “Current Events” is still being displayed obviously. How can I solve that ? I guess I should test $child somehow… If someone could point me in the right direction that would be nice ![]()
Cheers,
Daniel

