Hi,
I have to set this type of entries :
- Incomming
- project 1
- project 2
- Now
- project 3
- project 4
- Past (this year)
- project 5
- project 6
- Past (< this year)
- 2019
- project 7
- project 8
- 2018
- project 9
- project 10
The hard part for me is to separate past projects from this year and < year and for previous year, I have to sort projects by years.
<?php
$groups = $site->find('programme')->children()->listed()->sortBy('date_start', 'desc')->group(function($article) {
$today = date('Y-m-d');
$datestart = $article->date_start()->toDate('Y-m-d');
$dateend = $article->date_end()->toDate('Y-m-d') ;
$datearray = getDatesFromRange($datestart, $dateend);
if(in_array($today, $datearray)) return 'En cours';
if($datestart > $today) return 'a venir';
return 'passe';
});
?>
<?php foreach($groups as $description => $items): ?>
<ul class="container">
<?php foreach($items->sortBy('date_start', 'desc') as $page): ?>
<?php if($description == 'a venir'): ?>
<li class="grid-item avenir">
... Incomming
</li>
<?php elseif($description == 'passe'): ?>
<li class="grid-item passe">
... Past
</li>
<?php else: ?>
<li class="grid-item">
... Current
</li>
<?php endif ?>
<?php endforeach ?>
</ul>
<?php endforeach ?>
With these lines, I get only this type of sorting
Incomming
- project 1
- project 2
Now
- project 3
- project 4
Past (every years)
- project 5
- project 6
- project 7
- project 8
- project 9
- project 10