fix next / previous events
This commit is contained in:
parent
e5e8cad6ca
commit
94cf47ee43
3 changed files with 14 additions and 9 deletions
|
|
@ -82,8 +82,7 @@ return function($kirby, $page) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'pastEvents' => filterPastEvents($kirby->collection('ordered-season')),
|
'events' => splitNextAndPreviousEvents($kirby->collection('ordered-season')),
|
||||||
'futureEvents' => filterFutureEvents($kirby->collection('ordered-season')),
|
|
||||||
'currentSeasonSessions' => sortByMonth($currentSeasonSessions)
|
'currentSeasonSessions' => sortByMonth($currentSeasonSessions)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
@ -19,8 +19,9 @@ function getMonthNumber($month) {
|
||||||
return $array[$month];
|
return $array[$month];
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterFutureEvents($events) {
|
function splitNextAndPreviousEvents($events) {
|
||||||
$futureEvents = new Pages();
|
$next = new Pages();
|
||||||
|
$previous = new Pages();
|
||||||
|
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
$sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions()->toStructure() : $event->sessions()->toStructure();
|
$sessions = $event->isMapadoEvent() == 'true' ? $event->remoteSessions()->toStructure() : $event->sessions()->toStructure();
|
||||||
|
|
@ -41,11 +42,16 @@ function filterFutureEvents($events) {
|
||||||
|
|
||||||
|
|
||||||
if (!empty($futureDates)) {
|
if (!empty($futureDates)) {
|
||||||
$futureEvents->add($event);
|
$next->add($event);
|
||||||
|
} else {
|
||||||
|
$previous->add($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $futureEvents;
|
return [
|
||||||
|
'next' => $next,
|
||||||
|
'previous' => $previous,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterPastEvents($events) {
|
function filterPastEvents($events) {
|
||||||
|
|
|
||||||
|
|
@ -107,12 +107,12 @@
|
||||||
<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' => $futureEvents, 'columns' => 3]) ?>
|
<?php snippet('events-grid', ['events' => $events['next'], 'columns' => 3]) ?>
|
||||||
<?php if ($pastEvents->count() > 0): ?>
|
<?php if ($events['previous']->count() > 0): ?>
|
||||||
<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' => $pastEvents, 'columns' => 3]) ?>
|
<?php snippet('events-grid', ['events' => $events['previous'], 'columns' => 3]) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue