Structured Field: Hide entry when the date is over


im using a Structure Field for dates. The code looks like this and works fine:

<?php foreach($page->termine()->toStructure()->sortBy('date', 'asc') as $termin): ?>
  <time datetime="<?php echo $termin->date('c') ?>"><?php echo $termin->date('d.m.Y') ?></time>
  <?php echo $termin->titel()->kirbytext() ?>
<?php endforeach ?>

The Blueprint is:

    label: Termine
    type: structure
    style: table
        label: Titel
        type: text
        label: Datum
        type: date
        format: DD.MM.YYYY
        default: today

Is it possible to hide entries automatically when the day of the date is over?

Thanks in advance

With pages you can use ->hide() like that:

$adate = time();
$edate = strtotime($event->date());
if ($adate > $edate) {

With structure fields you would probably have to add another toggle field that defines the visibility. Otherwise you would have to delete the entry.

You can filter your entries by date:

$termine = $page->termine()->toStructure()->filterBy('date', '>', time())->sortBy('date', 'asc');
1 Like

Thats exactly what i was looking for, i didnt expect it to be that easy. Thanks for your help @thguenther and @texnixe