index-main/site/templates/investigations.php
Julie Blanc ec72fa474c
All checks were successful
Deploy / Deploy to Production (push) Successful in 17s
complete dossier
2026-02-26 17:54:47 +01:00

107 lines
3.8 KiB
PHP

<?php snippet('header') ?>
<main>
<header class="page__header">
<h2 class="page__title"><?= $page->title() ?></h2>
<?php if ($page->chapo()->isNotEmpty()): ?>
<div class="page__description">
<p><?= $page->chapo() ?></p>
</div>
<?php endif ?>
</header>
<div class="page__sort">
<button class="sort btn--small no-link" data-sort-type="down"><p>Trier par date</p> <span class="arrow"><?= svg('assets/icons/arrow-left.svg') ?></span></button>
<div class="dropdown">
<button class="dropdown__trigger sort btn--small no-link"><span class="icon"><?= svg('assets/icons/filter.svg') ?></span><p>Lieux</p></button>
<div class="dropdown__content">
<ul>
<?php foreach (page('database')->countries()->split() as $cat): ?>
<li><button type="button" data-filter="<?= esc(Str::slug($cat)) ?>"><?= esc($cat) ?></button></li>
<?php endforeach ?>
<li><button type="button" data-filter=""><?= t('filter.all.m') ?></button></li>
</ul>
</div>
</div>
</div>
<section class="container-cards container-cards__investigations" data-sort-container>
<?php foreach ($page->children()->listed()->sortBy('created', 'desc') as $investigation):
$cover = $investigation->cover()->toFile();
$dateAttr = $investigation->incidentDate()->isNotEmpty()
? $investigation->incidentDate()->toDate('yyyy-MM-dd')
: ($investigation->created()->isNotEmpty() ? $investigation->created()->toDate('yyyy-MM-dd') : '');
$filterAttr = implode(' ', array_map(fn($c) => Str::slug($c), $investigation->incidentCountry()->split()));
?>
<article class="card--article"
data-date="<?= esc($dateAttr) ?>"
data-filter="<?= esc($filterAttr) ?>">
<?php if ($cover): ?>
<figure>
<img src="<?= $cover->url() ?>" alt="<?= $investigation->title()->esc() ?>">
</figure>
<?php endif ?>
<div class="content">
<h4 class="title"><a href="<?= $investigation->url() ?>"><?= $investigation->title()->esc() ?></a></h4>
<?php if ($investigation->chapo()->isNotEmpty()): ?>
<p class="description"><?= $investigation->chapo()->excerpt(200) ?></p>
<?php endif ?>
<dl class="dl">
<?php if ($investigation->incidentDate()->isNotEmpty()): ?>
<div class="dl__group">
<dt>Date de l'incident</dt>
<dd><time datetime="<?= $investigation->incidentDate()->toDate('yyyy-MM-dd') ?>"><?= $investigation->incidentDate()->toDate('d MMMM yyyy', 'fr_FR') ?></time></dd>
</div>
<?php endif ?>
<?php if ($partners = $investigation->partners()->toStructure()): ?>
<?php if ($partners->isNotEmpty()): ?>
<div class="dl__group">
<dt>Partenaire(s)</dt>
<dd>
<?php $partnerNames = [] ?>
<?php foreach ($partners as $partner): ?>
<?php $partnerNames[] = $partner->name()->value() ?>
<?php endforeach ?>
<?= implode(', ', $partnerNames) ?>
</dd>
</div>
<?php endif ?>
<?php endif ?>
<?php if ($investigation->incidentLocation()->isNotEmpty()): ?>
<div class="dl__group">
<dt>Lieu de l'incident</dt>
<dd><?= $investigation->incidentLocation()->esc() ?></dd>
</div>
<?php endif ?>
</dl>
</div>
<?php if ($keywords = $investigation->keywords()->split()): ?>
<div class="keywords-wrapper">
<ul class="keywords">
<?php foreach ($keywords as $keyword): ?>
<li><a href="#keyword" target="_blank"><?= esc($keyword) ?></a></li>
<?php endforeach ?>
</ul>
</div>
<?php endif ?>
<a class="link-block" href="<?= $investigation->url() ?>"></a>
</article>
<?php endforeach ?>
</section>
</main>
<?php snippet('footer') ?>