So, I have a list of events where some events are not sorted in ascending order depending on the date for some reason. Can anybody explain why?
This is the blueprint:
termine:
type: pages
create: termin
empty: Eintrag hinzufügen
layout: table
image: false
text: false
columns:
beginn_datum:
label: Datum
value: "{{ page.beginn_datum.toDate('d.m.Y') }}"
mobile: true
title:
label: Veranstaltung
type: html
mobile: true
value: '<span class="k-url-field-preview" data-link="{{ page.panel.url }}" style="padding: 0"><a class="k-link" href="{{ page.panel.url }}">{{ page.title }}</a><span>'
width: 2/3
sortBy: beginn_datum asc
this is the relevant template code:
<?php
$termine = $page->children()->filter(function($item) {
return $item->beginn_datum()->toDate() >= time();
});
if($termine):
?>
<?php foreach($termine as $termin): ?>
…
…
<?php endforeach; ?>
<?php endif; ?>
For some reason, events where no start time has been specified are printed before events with start time, even if the start date is after those. For example, an event beginning on 2024-05-15 at 16:00 hours is printed after an event beginning on 2024-06-01 without start time (or rather, the event without start time is printed before all events with start time).
They are in the right order in the panel. This seems to be an issue with the filter but I can’t figure out what. Please help!