start program page
This commit is contained in:
parent
f75d7b390e
commit
3694b55357
10 changed files with 150 additions and 52 deletions
35
site/controllers/program.php
Normal file
35
site/controllers/program.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
return function($page) {
|
||||
$currentSeason = $page->children()->first();
|
||||
$today = date('Ymd');
|
||||
|
||||
$previousEvents = new Pages();
|
||||
$nextEvents = new Pages();
|
||||
|
||||
foreach ($currentSeason->children() as $event) {
|
||||
$sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions() : $event->sessions();
|
||||
|
||||
$isStillShowing = false;
|
||||
|
||||
foreach ($sessions->toStructure() as $session) {
|
||||
$sessionDate = str_replace('-', '', $session->date()->toDate('YMMdd'));
|
||||
|
||||
if ($sessionDate >= $today) {
|
||||
$isStillShowing = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($isStillShowing) {
|
||||
$nextEvents->add($event);
|
||||
} else {
|
||||
$previousEvents->add($event);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'previousEvents' => $previousEvents,
|
||||
'nextEvents' => $nextEvents
|
||||
];
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue