Hey,
I have a structure field with dates.
Plus some if statements. Expired dates are not displayed.
I would like to hide the complete container if no dates has been entered or all dates are in the past.
<div>
<?php $items = $page->freie_zeiten()->toStructure();
foreach ($items as $item): ?>
<?php $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
if($item->bis()->toDate() > $today): ?>
<div>
<?php $today_von = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
if($item->von()->toDate() > $today_von): ?>
<?= $item->von()->toDate('d.m.Y') ?> -
<?php else: ?>
bis
<?php endif ?>
<?= $item->bis()->toDate('d.m.Y') ?>
</div>
<?php endif ?>
<?php endforeach ?>
</div>
I think I would have to call the single item before the foreach loop.
But I failed.
That was an idea:
<?php
$items = $page->freie_zeiten()->toStructure();
$item = ????
...
if($item->count() < 1):
?>
<div>
...
foreach loop
...
</div>
<?php endif ?>
Thank you for your help.