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
|
||||
icon: page
|
||||
fields:
|
||||
mainBaseline:
|
||||
label: Baseline
|
||||
type: text
|
||||
help: À gauche des enquêtes.
|
||||
width: 1/2
|
||||
impactsBaseline:
|
||||
label: Phrase d'introduction des impacts
|
||||
type: text
|
||||
help: À gauche des impacts.
|
||||
width: 1/2
|
||||
sections:
|
||||
label: Sections
|
||||
type: structure
|
||||
fields:
|
||||
baseline:
|
||||
label: Baseline (colonne gauche)
|
||||
type: text
|
||||
width: 1/1
|
||||
buttonText:
|
||||
label: Texte du bouton
|
||||
type: text
|
||||
width: 1/2
|
||||
buttonLink:
|
||||
label: Lien du bouton
|
||||
type: url
|
||||
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
|
||||
seo: seo/page
|
||||
|
|
|
|||
|
|
@ -1,63 +1,88 @@
|
|||
<?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>
|
||||
|
||||
<?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="col-left">
|
||||
<p class="baseline-section"><?= $page->mainBaseline() ?></p>
|
||||
<button class="btn--bold-inline">
|
||||
<a href="#">
|
||||
<span class="text">En savoir plus</span>
|
||||
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
||||
<div class="col-left">
|
||||
<?php if ($section->baseline()->isNotEmpty()): ?>
|
||||
<p class="baseline-section"><?= $section->baseline() ?></p>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($section->buttonText()->isNotEmpty()): ?>
|
||||
<button class="btn--bold-inline">
|
||||
<a href="<?= $section->buttonLink()->esc() ?>">
|
||||
<span class="text"><?= $section->buttonText()->esc() ?></span>
|
||||
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
</button>
|
||||
<?php endif ?>
|
||||
</div><!-- .col-left -->
|
||||
|
||||
<div class="col-right">
|
||||
|
||||
<?php
|
||||
$enquetesPage = page('enquetes');
|
||||
$superPin = $enquetesPage->superPinnedInvestigation()->toPage();
|
||||
$pinned = $enquetesPage->pinnedInvestigations()->toPages();
|
||||
if ($superPin) $pinned = $pinned->not($superPin);
|
||||
<?php if ($type === 'investigations'): ?>
|
||||
|
||||
$list = [];
|
||||
$shownIds = [];
|
||||
<?php
|
||||
$enquetesPage = page('enquetes');
|
||||
$superPin = $enquetesPage->superPinnedInvestigation()->toPage();
|
||||
$pinned = $enquetesPage->pinnedInvestigations()->toPages();
|
||||
if ($superPin) $pinned = $pinned->not($superPin);
|
||||
|
||||
if ($superPin) {
|
||||
$list[] = ['page' => $superPin, 'type' => 'super'];
|
||||
$shownIds[] = $superPin->id();
|
||||
}
|
||||
$list = [];
|
||||
$shownIds = [];
|
||||
|
||||
foreach ($pinned as $p) {
|
||||
if (count($list) >= 5) break;
|
||||
$list[] = ['page' => $p, 'type' => 'pinned'];
|
||||
$shownIds[] = $p->id();
|
||||
}
|
||||
|
||||
if (count($list) < 5) {
|
||||
$latest = $enquetesPage->children()->listed()->sortBy('created', 'desc')
|
||||
->filter(fn($p) => !in_array($p->id(), $shownIds))
|
||||
->limit(5 - count($list));
|
||||
foreach ($latest as $p) {
|
||||
$list[] = ['page' => $p, 'type' => 'latest'];
|
||||
if ($superPin) {
|
||||
$list[] = ['page' => $superPin, 'type' => 'super'];
|
||||
$shownIds[] = $superPin->id();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php foreach ($list as $item):
|
||||
$investigation = $item['page'];
|
||||
$type = $item['type'];
|
||||
$cover = $investigation->cover()->toFile();
|
||||
?>
|
||||
<article class="card--article<?= $type === 'super' ? ' pinned-home' : ($type === 'pinned' ? ' pinned' : '') ?>">
|
||||
foreach ($pinned as $p) {
|
||||
if (count($list) >= $count) break;
|
||||
$list[] = ['page' => $p, 'type' => 'pinned'];
|
||||
$shownIds[] = $p->id();
|
||||
}
|
||||
|
||||
<?php if ($type === 'super' && ($videoPreview = $investigation->videoPreview()->toFile())): ?>
|
||||
if (count($list) < $count) {
|
||||
$latest = $enquetesPage->children()->listed()->sortBy('created', 'desc')
|
||||
->filter(fn($p) => !in_array($p->id(), $shownIds))
|
||||
->limit($count - count($list));
|
||||
foreach ($latest as $p) {
|
||||
$list[] = ['page' => $p, 'type' => 'latest'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php foreach ($list as $item):
|
||||
$investigation = $item['page'];
|
||||
$itype = $item['type'];
|
||||
$cover = $investigation->cover()->toFile();
|
||||
?>
|
||||
<article class="card--article<?= $itype === 'super' ? ' pinned-home' : ($itype === 'pinned' ? ' pinned' : '') ?>">
|
||||
|
||||
<?php if ($itype === 'super' && ($videoPreview = $investigation->videoPreview()->toFile())): ?>
|
||||
<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>
|
||||
<?php elseif ($cover): ?>
|
||||
<figure>
|
||||
|
|
@ -65,7 +90,7 @@
|
|||
</figure>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($type === 'pinned'): ?>
|
||||
<?php if ($itype === 'pinned'): ?>
|
||||
<div class="pin"><?= svg('assets/icons/pin.svg') ?></div>
|
||||
<?php endif ?>
|
||||
|
||||
|
|
@ -79,24 +104,16 @@
|
|||
<?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>
|
||||
<dd><time datetime="<?= $investigation->incidentDate()->toDate('yyyy-MM-dd') ?>"><?= $investigation->incidentDate()->toDate('d MMMM yyyy', $dateLocale) ?></time></dd>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($partners = $investigation->partners()->toStructure()): ?>
|
||||
<?php if ($partners->isNotEmpty()): ?>
|
||||
<?php if (($partners = $investigation->partners()->toStructure()) && $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>
|
||||
<dd><?php $names = []; foreach ($partners as $partner) $names[] = $partner->name()->value(); echo implode(', ', $names) ?></dd>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($investigation->incidentLocation()->isNotEmpty()): ?>
|
||||
<div class="dl__group">
|
||||
|
|
@ -118,112 +135,184 @@
|
|||
|
||||
<a class="link-block" href="<?= $investigation->url() ?>"></a>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
<?php endforeach ?>
|
||||
|
||||
|
||||
<?php elseif ($type === 'impacts'): ?>
|
||||
|
||||
<div class="grid-masonry">
|
||||
<div class="grid-sizer"></div>
|
||||
|
||||
<?php foreach (page('impacts')->children()->listed()->sortBy('created', 'desc')->limit($count) as $impact):
|
||||
$categories = $impact->category()->split();
|
||||
$category = $categories[0] ?? '';
|
||||
$cover = $impact->cover()->toFile();
|
||||
$investigations = $impact->linkedInvestigations()->toPages();
|
||||
?>
|
||||
<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): ?>
|
||||
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="group-top">
|
||||
<p class="type">Impact</p>
|
||||
<?php if ($category): ?>
|
||||
<p class="category"><?= esc($category) ?></p>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
||||
<h3 class="title"><?= $impact->title()->esc() ?></h3>
|
||||
|
||||
<?php if ($impact->created()->isNotEmpty()): ?>
|
||||
<p class="date"><time datetime="<?= $impact->created()->toDate('yyyy-MM-dd') ?>"><?= $impact->created()->toDate('d MMMM yyyy', $dateLocale) ?></time></p>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($investigations->isNotEmpty()): ?>
|
||||
<ul class="investigations">
|
||||
<?php foreach ($investigations as $investigation): ?>
|
||||
<li><a href="<?= $investigation->url() ?>"><?= $investigation->title()->esc() ?></a></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
|
||||
<a class="link-block" href="<?= $impact->url() ?>"></a>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
<?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">
|
||||
<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 href="<?= esc($seeMoreUrl) ?>">
|
||||
<span class="text"><?= esc($seeMoreLabel) ?></span>
|
||||
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div> <!-- col-right-->
|
||||
</div>
|
||||
</div><!-- .col-right -->
|
||||
</div><!-- .section--inner -->
|
||||
</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-sizer"></div>
|
||||
|
||||
<?php
|
||||
$impactsPage = page('impacts');
|
||||
foreach ($impactsPage->children()->listed()->sortBy('created', 'desc')->limit(8) as $impact):
|
||||
$categories = $impact->category()->split();
|
||||
$category = $categories[0] ?? '';
|
||||
$cover = $impact->cover()->toFile();
|
||||
$investigations = $impact->linkedInvestigations()->toPages();
|
||||
?>
|
||||
<div class="card--block has-link">
|
||||
|
||||
<?php if ($cover): ?>
|
||||
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="group-top">
|
||||
<p class="type">Impact</p>
|
||||
<?php if ($category): ?>
|
||||
<p class="category"><?= esc($category) ?></p>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
||||
<h3 class="title"><?= $impact->title()->esc() ?></h3>
|
||||
|
||||
<?php if ($impact->created()->isNotEmpty()): ?>
|
||||
<p class="date"><?= $impact->created()->toDate('d MMMM yyyy', 'fr_FR') ?></p>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($investigations->isNotEmpty()): ?>
|
||||
<ul class="investigations">
|
||||
<?php foreach ($investigations as $investigation): ?>
|
||||
<li><a href="<?= $investigation->url() ?>"><?= $investigation->title()->esc() ?></a></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
|
||||
<a class="link-block" href="<?= $impact->url() ?>"></a>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
|
||||
</div> <!-- end masonry -->
|
||||
|
||||
<div class="see-more">
|
||||
<button class="btn--bold-inline">
|
||||
<a href="/impacts">
|
||||
<span class="text">Voir tout</span>
|
||||
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php endforeach ?>
|
||||
|
||||
</main>
|
||||
<?php snippet('footer') ?>
|
||||
<?php snippet('footer') ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue