Dates in structure field from child pages

finally :grinning: it works :wink:

this is my collection-file:

<?php

return function ($site) {
    $projects = $site->find('produktionen')->children()->listed();
    $collection = [];

    foreach ($projects as $project) {
        foreach ($project->termine()->toStructure() as $item) {
            $collection[] = [
                'slug'     => $project->slug() . '-' . $item->datum()->toDate('EE, dd. MMM YYYY'),
                'template' => $project->intendedTemplate()->name(),
                'content'  => array_merge(
                    $project->content()->toArray(),
                    ['datum' => $item->datum()->toDate('EE, dd. MMM YYYY'),
                     'zeit' => $item->zeit(),
                     'zusatz' => $item->zusatz()]
                ),
            ];
        }
    }
  

  return Pages::factory($collection)->sortBy('datum', 'asc')->groupBy('datum', 'asc');
  };

and this ist my template-file:

<?php $kirby->collection('lineup'); ?>    
  
<?php foreach ($kirby->collection('lineup') as $date => $items): ?>
    <h2><?= $date ?></h2>
        <?php foreach ($items as $project): ?>
          <?= $project->title() ?>
          <?= $project->untertitel(); ?>
          <?= $project->zeit() ?> Uhr 
          <?= $project->zusatz() ?></br>
        <?php endforeach ?>   
<?php endforeach ?>

the only thing left is: the sorting by date …
for now it seems the dates are sorted kind of weired … I tried to add ‘asc’ as you can see in the collection-file - but that has no effect … maybe you have an idea?

many many many thanks so far!!! :wink: