This commit is contained in:
parent
7fc8ab6c5a
commit
69e0b3527e
2 changed files with 272 additions and 160 deletions
|
|
@ -5,14 +5,37 @@ tabs:
|
||||||
label: Contenu
|
label: Contenu
|
||||||
icon: page
|
icon: page
|
||||||
fields:
|
fields:
|
||||||
mainBaseline:
|
sections:
|
||||||
label: Baseline
|
label: Sections
|
||||||
|
type: structure
|
||||||
|
fields:
|
||||||
|
baseline:
|
||||||
|
label: Baseline (colonne gauche)
|
||||||
|
type: text
|
||||||
|
width: 1/1
|
||||||
|
buttonText:
|
||||||
|
label: Texte du bouton
|
||||||
type: text
|
type: text
|
||||||
help: À gauche des enquêtes.
|
|
||||||
width: 1/2
|
width: 1/2
|
||||||
impactsBaseline:
|
buttonLink:
|
||||||
label: Phrase d'introduction des impacts
|
label: Lien du bouton
|
||||||
type: text
|
type: url
|
||||||
help: À gauche des impacts.
|
width: 1/2
|
||||||
|
contentType:
|
||||||
|
label: Type de contenu
|
||||||
|
type: select
|
||||||
|
required: true
|
||||||
|
options:
|
||||||
|
investigations: "Enquêtes"
|
||||||
|
impacts: Impacts
|
||||||
|
packages: Dossiers
|
||||||
|
projects: "Projets (Lab)"
|
||||||
|
news: "Brèves"
|
||||||
|
width: 1/2
|
||||||
|
count:
|
||||||
|
label: "Nombre d'éléments (min. 4)"
|
||||||
|
type: number
|
||||||
|
min: 4
|
||||||
|
default: 6
|
||||||
width: 1/2
|
width: 1/2
|
||||||
seo: seo/page
|
seo: seo/page
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,48 @@
|
||||||
<?php snippet('header') ?>
|
<?php snippet('header') ?>
|
||||||
|
<?php
|
||||||
|
$lang = kirby()->language();
|
||||||
|
$locale = $lang ? $lang->locale(LC_ALL) : 'fr_FR.UTF-8';
|
||||||
|
$dateLocale = substr(is_array($locale) ? reset($locale) : $locale, 0, 5);
|
||||||
|
?>
|
||||||
<main>
|
<main>
|
||||||
|
|
||||||
|
<?php foreach ($page->sections()->toStructure() as $section):
|
||||||
|
|
||||||
|
$type = $section->contentType()->value();
|
||||||
|
$count = max(4, (int)$section->count()->value());
|
||||||
|
|
||||||
<section class="section--home" id="home__investigations">
|
[$seeMoreLabel, $seeMoreUrl] = match($type) {
|
||||||
|
'investigations' => ['Voir toutes les enquêtes', page('enquetes')->url()],
|
||||||
|
'impacts' => ['Voir tous les impacts', page('impacts')->url()],
|
||||||
|
'packages' => ['Voir tous les dossiers', page('packages')->url()],
|
||||||
|
'projects' => ['Voir tous les projets', site()->find('laboratoire')->url()],
|
||||||
|
'news' => ['Voir toutes les brèves', page('news')->url()],
|
||||||
|
default => ['Voir tout', '/'],
|
||||||
|
};
|
||||||
|
?>
|
||||||
|
|
||||||
|
<section class="section--home" id="home__<?= esc($type) ?>">
|
||||||
<div class="section--inner">
|
<div class="section--inner">
|
||||||
|
|
||||||
<div class="col-left">
|
<div class="col-left">
|
||||||
<p class="baseline-section"><?= $page->mainBaseline() ?></p>
|
<?php if ($section->baseline()->isNotEmpty()): ?>
|
||||||
|
<p class="baseline-section"><?= $section->baseline() ?></p>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if ($section->buttonText()->isNotEmpty()): ?>
|
||||||
<button class="btn--bold-inline">
|
<button class="btn--bold-inline">
|
||||||
<a href="#">
|
<a href="<?= $section->buttonLink()->esc() ?>">
|
||||||
<span class="text">En savoir plus</span>
|
<span class="text"><?= $section->buttonText()->esc() ?></span>
|
||||||
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
||||||
</a>
|
</a>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
<?php endif ?>
|
||||||
|
</div><!-- .col-left -->
|
||||||
|
|
||||||
<div class="col-right">
|
<div class="col-right">
|
||||||
|
|
||||||
|
<?php if ($type === 'investigations'): ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$enquetesPage = page('enquetes');
|
$enquetesPage = page('enquetes');
|
||||||
$superPin = $enquetesPage->superPinnedInvestigation()->toPage();
|
$superPin = $enquetesPage->superPinnedInvestigation()->toPage();
|
||||||
|
|
@ -33,15 +58,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($pinned as $p) {
|
foreach ($pinned as $p) {
|
||||||
if (count($list) >= 5) break;
|
if (count($list) >= $count) break;
|
||||||
$list[] = ['page' => $p, 'type' => 'pinned'];
|
$list[] = ['page' => $p, 'type' => 'pinned'];
|
||||||
$shownIds[] = $p->id();
|
$shownIds[] = $p->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($list) < 5) {
|
if (count($list) < $count) {
|
||||||
$latest = $enquetesPage->children()->listed()->sortBy('created', 'desc')
|
$latest = $enquetesPage->children()->listed()->sortBy('created', 'desc')
|
||||||
->filter(fn($p) => !in_array($p->id(), $shownIds))
|
->filter(fn($p) => !in_array($p->id(), $shownIds))
|
||||||
->limit(5 - count($list));
|
->limit($count - count($list));
|
||||||
foreach ($latest as $p) {
|
foreach ($latest as $p) {
|
||||||
$list[] = ['page' => $p, 'type' => 'latest'];
|
$list[] = ['page' => $p, 'type' => 'latest'];
|
||||||
}
|
}
|
||||||
|
|
@ -50,14 +75,14 @@
|
||||||
|
|
||||||
<?php foreach ($list as $item):
|
<?php foreach ($list as $item):
|
||||||
$investigation = $item['page'];
|
$investigation = $item['page'];
|
||||||
$type = $item['type'];
|
$itype = $item['type'];
|
||||||
$cover = $investigation->cover()->toFile();
|
$cover = $investigation->cover()->toFile();
|
||||||
?>
|
?>
|
||||||
<article class="card--article<?= $type === 'super' ? ' pinned-home' : ($type === 'pinned' ? ' pinned' : '') ?>">
|
<article class="card--article<?= $itype === 'super' ? ' pinned-home' : ($itype === 'pinned' ? ' pinned' : '') ?>">
|
||||||
|
|
||||||
<?php if ($type === 'super' && ($videoPreview = $investigation->videoPreview()->toFile())): ?>
|
<?php if ($itype === 'super' && ($videoPreview = $investigation->videoPreview()->toFile())): ?>
|
||||||
<div class="video-extract">
|
<div class="video-extract">
|
||||||
<video class="vjs-tech" id="player-element_html5_api" tabindex="-1" loop="" muted="muted" playsinline="playsinline" autoplay="" src="<?= $videoPreview->url() ?>"></video>
|
<video class="vjs-tech" tabindex="-1" loop muted playsinline autoplay src="<?= $videoPreview->url() ?>"></video>
|
||||||
</div>
|
</div>
|
||||||
<?php elseif ($cover): ?>
|
<?php elseif ($cover): ?>
|
||||||
<figure>
|
<figure>
|
||||||
|
|
@ -65,7 +90,7 @@
|
||||||
</figure>
|
</figure>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if ($type === 'pinned'): ?>
|
<?php if ($itype === 'pinned'): ?>
|
||||||
<div class="pin"><?= svg('assets/icons/pin.svg') ?></div>
|
<div class="pin"><?= svg('assets/icons/pin.svg') ?></div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
|
@ -79,24 +104,16 @@
|
||||||
<?php if ($investigation->incidentDate()->isNotEmpty()): ?>
|
<?php if ($investigation->incidentDate()->isNotEmpty()): ?>
|
||||||
<div class="dl__group">
|
<div class="dl__group">
|
||||||
<dt>Date de l'incident</dt>
|
<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>
|
<dd><time datetime="<?= $investigation->incidentDate()->toDate('yyyy-MM-dd') ?>"><?= $investigation->incidentDate()->toDate('d MMMM yyyy', $dateLocale) ?></time></dd>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if ($partners = $investigation->partners()->toStructure()): ?>
|
<?php if (($partners = $investigation->partners()->toStructure()) && $partners->isNotEmpty()): ?>
|
||||||
<?php if ($partners->isNotEmpty()): ?>
|
|
||||||
<div class="dl__group">
|
<div class="dl__group">
|
||||||
<dt>Partenaire(s)</dt>
|
<dt>Partenaire(s)</dt>
|
||||||
<dd>
|
<dd><?php $names = []; foreach ($partners as $partner) $names[] = $partner->name()->value(); echo implode(', ', $names) ?></dd>
|
||||||
<?php $partnerNames = [] ?>
|
|
||||||
<?php foreach ($partners as $partner): ?>
|
|
||||||
<?php $partnerNames[] = $partner->name()->value() ?>
|
|
||||||
<?php endforeach ?>
|
|
||||||
<?= implode(', ', $partnerNames) ?>
|
|
||||||
</dd>
|
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php endif ?>
|
|
||||||
|
|
||||||
<?php if ($investigation->incidentLocation()->isNotEmpty()): ?>
|
<?php if ($investigation->incidentLocation()->isNotEmpty()): ?>
|
||||||
<div class="dl__group">
|
<div class="dl__group">
|
||||||
|
|
@ -120,58 +137,21 @@
|
||||||
</article>
|
</article>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
|
<?php elseif ($type === 'impacts'): ?>
|
||||||
|
|
||||||
|
|
||||||
<div class="see-more">
|
|
||||||
<button class="btn--bold-inline">
|
|
||||||
<a href="/enquetes">
|
|
||||||
<span class="text">Voir toutes les enquêtes</span>
|
|
||||||
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
|
||||||
</a>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div> <!-- col-right-->
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section class="section--home" id="home__impacts">
|
|
||||||
<div class="section--inner">
|
|
||||||
|
|
||||||
<div class="col-left">
|
|
||||||
|
|
||||||
<p class="baseline-section"><?= $page->impactsBaseline() ?></p>
|
|
||||||
|
|
||||||
|
|
||||||
<button class="btn--bold-inline">
|
|
||||||
<a href="/impacts">
|
|
||||||
<span class="text">En savoir plus</span>
|
|
||||||
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
|
||||||
</a>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-right">
|
|
||||||
|
|
||||||
<div class="grid-masonry">
|
<div class="grid-masonry">
|
||||||
|
|
||||||
<div class="grid-sizer"></div>
|
<div class="grid-sizer"></div>
|
||||||
|
|
||||||
<?php
|
<?php foreach (page('impacts')->children()->listed()->sortBy('created', 'desc')->limit($count) as $impact):
|
||||||
$impactsPage = page('impacts');
|
|
||||||
foreach ($impactsPage->children()->listed()->sortBy('created', 'desc')->limit(8) as $impact):
|
|
||||||
$categories = $impact->category()->split();
|
$categories = $impact->category()->split();
|
||||||
$category = $categories[0] ?? '';
|
$category = $categories[0] ?? '';
|
||||||
$cover = $impact->cover()->toFile();
|
$cover = $impact->cover()->toFile();
|
||||||
$investigations = $impact->linkedInvestigations()->toPages();
|
$investigations = $impact->linkedInvestigations()->toPages();
|
||||||
?>
|
?>
|
||||||
<div class="card--block has-link">
|
<div class="card--block has-link"
|
||||||
|
data-impact-type="<?= esc(Str::slug($category)) ?>"
|
||||||
|
data-filter="<?= esc(Str::slug($category)) ?>"
|
||||||
|
data-date="<?= $impact->created()->isNotEmpty() ? $impact->created()->toDate('yyyy-MM-dd') : '' ?>">
|
||||||
|
|
||||||
<?php if ($cover): ?>
|
<?php if ($cover): ?>
|
||||||
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
|
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
|
||||||
|
|
@ -187,7 +167,7 @@
|
||||||
<h3 class="title"><?= $impact->title()->esc() ?></h3>
|
<h3 class="title"><?= $impact->title()->esc() ?></h3>
|
||||||
|
|
||||||
<?php if ($impact->created()->isNotEmpty()): ?>
|
<?php if ($impact->created()->isNotEmpty()): ?>
|
||||||
<p class="date"><?= $impact->created()->toDate('d MMMM yyyy', 'fr_FR') ?></p>
|
<p class="date"><time datetime="<?= $impact->created()->toDate('yyyy-MM-dd') ?>"><?= $impact->created()->toDate('d MMMM yyyy', $dateLocale) ?></time></p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if ($investigations->isNotEmpty()): ?>
|
<?php if ($investigations->isNotEmpty()): ?>
|
||||||
|
|
@ -201,29 +181,138 @@
|
||||||
<a class="link-block" href="<?= $impact->url() ?>"></a>
|
<a class="link-block" href="<?= $impact->url() ?>"></a>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div> <!-- end masonry -->
|
<?php elseif ($type === 'packages'): ?>
|
||||||
|
|
||||||
|
<div class="container-cards">
|
||||||
|
<?php foreach (page('packages')->children()->listed()->limit($count) as $package):
|
||||||
|
$cover = $package->cover()->toFile();
|
||||||
|
$investigationsCount = $package->linkedContent()->toPages()->count();
|
||||||
|
$impactsCount = $package->linkedImpacts()->toPages()->count();
|
||||||
|
?>
|
||||||
|
<article class="card--package">
|
||||||
|
<?php if ($cover): ?>
|
||||||
|
<figure>
|
||||||
|
<img src="<?= $cover->url() ?>" alt="<?= $package->title()->esc() ?>">
|
||||||
|
</figure>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<p class="type"><?= t('package.type') ?></p>
|
||||||
|
<h4 class="title">
|
||||||
|
<a href="<?= $package->url() ?>">
|
||||||
|
<span class="icon"><?= svg('assets/icons/package.svg') ?></span>
|
||||||
|
<?= $package->title()->esc() ?>
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<?php if ($investigationsCount > 0 || $impactsCount > 0): ?>
|
||||||
|
<ul class="details">
|
||||||
|
<?php if ($investigationsCount > 0): ?>
|
||||||
|
<li><?= $investigationsCount ?> enquête<?= $investigationsCount > 1 ? 's' : '' ?></li>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if ($impactsCount > 0): ?>
|
||||||
|
<li><?= $impactsCount ?> impact<?= $impactsCount > 1 ? 's' : '' ?></li>
|
||||||
|
<?php endif ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn--go-to"><a href="<?= $package->url() ?>"><?= svg('assets/icons/arrow-left.svg') ?></a></button>
|
||||||
|
<a class="link-block" href="<?= $package->url() ?>" aria-hidden="true"></a>
|
||||||
|
</article>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php elseif ($type === 'projects'): ?>
|
||||||
|
|
||||||
|
<div class="grid-masonry">
|
||||||
|
<div class="grid-sizer"></div>
|
||||||
|
|
||||||
|
<?php foreach (site()->find('laboratoire')->children()->listed()->sortBy('created', 'desc')->limit($count) as $project):
|
||||||
|
$categories = $project->category()->split();
|
||||||
|
$category = $categories[0] ?? '';
|
||||||
|
$cover = $project->cover()->toFile();
|
||||||
|
?>
|
||||||
|
<div class="card--block has-link"
|
||||||
|
data-filter="<?= esc(Str::slug($category)) ?>"
|
||||||
|
data-date="<?= $project->created()->isNotEmpty() ? $project->created()->toDate('yyyy-MM-dd') : '' ?>">
|
||||||
|
|
||||||
|
<?php if ($cover): ?>
|
||||||
|
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<div class="group-top">
|
||||||
|
<p class="type">Projet</p>
|
||||||
|
<?php if ($category): ?>
|
||||||
|
<p class="category"><?= esc($category) ?></p>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3 class="title"><?= $project->title()->esc() ?></h3>
|
||||||
|
|
||||||
|
<?php if ($project->created()->isNotEmpty()): ?>
|
||||||
|
<p class="date"><time datetime="<?= $project->created()->toDate('yyyy-MM-dd') ?>"><?= $project->created()->toDate('d MMMM yyyy', $dateLocale) ?></time></p>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<a class="link-block" href="<?= $project->url() ?>"></a>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php elseif ($type === 'news'): ?>
|
||||||
|
|
||||||
|
<div class="grid-masonry">
|
||||||
|
<div class="grid-sizer"></div>
|
||||||
|
|
||||||
|
<?php foreach (page('news')->children()->listed()->sortBy('created', 'desc')->limit($count) as $newsItem):
|
||||||
|
$categories = $newsItem->category()->split();
|
||||||
|
$category = $categories[0] ?? '';
|
||||||
|
$cover = $newsItem->cover()->toFile();
|
||||||
|
?>
|
||||||
|
<div class="card--block has-link"
|
||||||
|
data-filter="<?= esc(Str::slug($category)) ?>"
|
||||||
|
data-date="<?= $newsItem->created()->isNotEmpty() ? $newsItem->created()->toDate('yyyy-MM-dd') : '' ?>">
|
||||||
|
|
||||||
|
<?php if ($cover): ?>
|
||||||
|
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<div class="group-top">
|
||||||
|
<p class="type">Brève</p>
|
||||||
|
<?php if ($category): ?>
|
||||||
|
<p class="category"><?= esc($category) ?></p>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3 class="title"><?= $newsItem->title()->esc() ?></h3>
|
||||||
|
|
||||||
|
<?php if ($newsItem->created()->isNotEmpty()): ?>
|
||||||
|
<p class="date"><time datetime="<?= $newsItem->created()->toDate('yyyy-MM-dd') ?>"><?= $newsItem->created()->toDate('d MMMM yyyy', $dateLocale) ?></time></p>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<a class="link-block" href="<?= $newsItem->url() ?>"></a>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<div class="see-more">
|
<div class="see-more">
|
||||||
<button class="btn--bold-inline">
|
<button class="btn--bold-inline">
|
||||||
<a href="/impacts">
|
<a href="<?= esc($seeMoreUrl) ?>">
|
||||||
<span class="text">Voir tout</span>
|
<span class="text"><?= esc($seeMoreLabel) ?></span>
|
||||||
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
||||||
</a>
|
</a>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div><!-- .col-right -->
|
||||||
|
</div><!-- .section--inner -->
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<?php endforeach ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
<?php snippet('footer') ?>
|
<?php snippet('footer') ?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue