create template packages
All checks were successful
Deploy / Deploy to Production (push) Successful in 5m17s

This commit is contained in:
Julie Blanc 2026-02-25 18:22:13 +01:00
parent f73b8cb90b
commit aba8b4f37e
20 changed files with 414 additions and 526 deletions

View file

@ -350,17 +350,17 @@ if ($relatedInvestigations->isEmpty()) {
<?php
// Récupérer le dossier associé à cette investigation
$packageSlug = $page->package()->value();
$package = null;
if (!empty($packageSlug) && site()->find('dossiers')) {
$package = site()->find('dossiers')->children()->filterBy('slug', $packageSlug)->first();
}
// Récupérer le dossier associé à cette investigation (reverse lookup via linkedContent)
$packagesParent = site()->find('packages');
$package = $packagesParent
? $packagesParent->children()->listed()->filter(fn($p) => $p->linkedContent()->toPages()->has($page))->first()
: null;
if ($package):
$investigationsCount = $package->linkedContent()->toPages()->count();
?>
<aside class="page__aside" id="package">
<h3 class="aside__title">Dans le dossier</h3>
<h3 class="aside__title"><?= t('packages.title') ?></h3>
<article class="card--package">
<?php if ($cover = $package->cover()->toFile()): ?>
@ -369,26 +369,17 @@ if ($package):
</figure>
<?php endif ?>
<div class="content">
<p class="type">Dossier</p>
<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
// Compter les enquêtes associées à ce dossier
$investigationsCount = site()->find('enquetes')->children()->listed()->filter(function($investigation) use ($package) {
return $investigation->package()->value() === $package->slug();
})->count();
?>
<?php if ($investigationsCount > 0): ?>
<ul class="details">
<?php if ($investigationsCount > 0): ?>
<li><?= $investigationsCount ?> enquête<?= $investigationsCount > 1 ? 's' : '' ?></li>
<?php endif ?>
<li>8 impacts</li>
<li><?= $investigationsCount ?> enquête<?= $investigationsCount > 1 ? 's' : '' ?></li>
</ul>
<?php endif ?>
</div>
<button class="btn--go-to"><a href="<?= $package->url() ?>" target="_blank"><?= svg('assets/icons/arrow-left.svg') ?></a></button>
<a class="link-block" href="<?= $package->url() ?>" target="_blank" aria-hidden="true"></a>
</article>
</aside>
@ -443,10 +434,7 @@ if ($package):
</main>
<?php snippet('bottom-bar') ?>
<?php snippet('footer') ?>