program - ordere events
This commit is contained in:
parent
61bc24c984
commit
b33cb5510d
3 changed files with 28 additions and 14 deletions
|
|
@ -45,13 +45,10 @@ function createArraySession($event, $session) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return function($page) {
|
return function($kirby, $page) {
|
||||||
$currentSeason = $page->children()->first();
|
$currentSeason = $page->children()->first();
|
||||||
$today = date('Ymd');
|
$today = date('Ymd');
|
||||||
|
|
||||||
$previousEvents = new Pages();
|
|
||||||
$nextEvents = new Pages();
|
|
||||||
|
|
||||||
$currentSeasonSessions = [];
|
$currentSeasonSessions = [];
|
||||||
|
|
||||||
foreach ($currentSeason->children() as $event) {
|
foreach ($currentSeason->children() as $event) {
|
||||||
|
|
@ -68,17 +65,11 @@ return function($page) {
|
||||||
$isStillShowing = true;
|
$isStillShowing = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($isStillShowing) {
|
|
||||||
$nextEvents->add($event);
|
|
||||||
} else {
|
|
||||||
$previousEvents->add($event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'previousEvents' => $previousEvents,
|
'pastEvents' => filterPastEvents($kirby->collection('ordered-season')),
|
||||||
'nextEvents' => $nextEvents,
|
'futureEvents' => filterFutureEvents($kirby->collection('ordered-season')),
|
||||||
'currentSeasonSessions' => sortByMonth($currentSeasonSessions)
|
'currentSeasonSessions' => sortByMonth($currentSeasonSessions)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
@ -22,6 +22,29 @@ function filterFutureEvents($events) {
|
||||||
return $futureEvents;
|
return $futureEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterPastEvents($events) {
|
||||||
|
$pastEvents = new Pages();
|
||||||
|
|
||||||
|
foreach ($events as $event) {
|
||||||
|
$sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions()->toStructure() : $event->sessions()->toStructure();
|
||||||
|
|
||||||
|
$sessionDates = $sessions->map(function($session) {
|
||||||
|
return $session->date()->value();
|
||||||
|
})->data;
|
||||||
|
|
||||||
|
// Filtrer les événements qui ont toutes leurs dates passées
|
||||||
|
$pastDates = array_filter($sessionDates, function ($date) {
|
||||||
|
return strtotime($date) <= time();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (count($pastDates) == count($sessionDates)) {
|
||||||
|
$pastEvents->add($event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pastEvents;
|
||||||
|
}
|
||||||
|
|
||||||
function buildFieldsString($requestFields) {
|
function buildFieldsString($requestFields) {
|
||||||
$fields = [];
|
$fields = [];
|
||||||
foreach ($requestFields as $field) {
|
foreach ($requestFields as $field) {
|
||||||
|
|
|
||||||
|
|
@ -70,11 +70,11 @@
|
||||||
<section class="yellow">
|
<section class="yellow">
|
||||||
<h2>Prochainement — <?= $page->children()->first()->title() ?></h2>
|
<h2>Prochainement — <?= $page->children()->first()->title() ?></h2>
|
||||||
</section>
|
</section>
|
||||||
<?php snippet('events-grid', ['events' => $nextEvents, 'columns' => 3]) ?>
|
<?php snippet('events-grid', ['events' => $futureEvents, 'columns' => 3]) ?>
|
||||||
<section class="yellow">
|
<section class="yellow">
|
||||||
<h2>Événements passés</h2>
|
<h2>Événements passés</h2>
|
||||||
</section>
|
</section>
|
||||||
<?php snippet('events-grid', ['events' => $previousEvents, 'columns' => 3]) ?>
|
<?php snippet('events-grid', ['events' => $pastEvents, 'columns' => 3]) ?>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue