add latest content at bottom
All checks were successful
Deploy / Deploy to Production (push) Successful in 12s

This commit is contained in:
Julie Blanc 2026-02-25 18:35:20 +01:00
parent b436ea2770
commit e36eae0b6f
2 changed files with 88 additions and 5 deletions

View file

@ -28,15 +28,19 @@
</header> </header>
<div class="page__content">
<?php if ($page->body()->isNotEmpty()): ?> <?php if ($page->body()->isNotEmpty()): ?>
<div class="page__content">
<?= $page->body()->toBlocks() ?> <?= $page->body()->toBlocks() ?>
</div>
<?php endif ?> <?php endif ?>
</div>
<?php $investigations = $page->linkedInvestigations()->toPages() ?> <?php $investigations = $page->linkedInvestigations()->toPages() ?>
<?php if ($investigations->isNotEmpty()): ?> <?php if ($investigations->isNotEmpty()): ?>
@ -75,6 +79,48 @@
<?php endif ?> <?php endif ?>
<?php
$lang = kirby()->language();
$locale = $lang ? $lang->locale(LC_ALL) : 'fr_FR.UTF-8';
$dateLocale = substr(is_array($locale) ? reset($locale) : $locale, 0, 5);
$latestImpacts = site()->find('impacts')
->children()->listed()->not($page)
->sortBy('created', 'desc')
->limit(5);
?>
<?php if ($latestImpacts->isNotEmpty()): ?>
<aside class="page__aside" id="latest-impacts">
<h3 class="aside__title">Voir aussi</h3>
<?php foreach ($latestImpacts as $impact): ?>
<div class="card--block-small has-link">
<div class="group-top">
<p class="type"><?= t('impact.type') ?></p>
<?php if ($impact->category()->isNotEmpty()): ?>
<p class="category"><?= $impact->category()->esc() ?></p>
<?php endif ?>
</div>
<h4 class="title"><?= $impact->title()->esc() ?></h4>
<?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 ?>
<button class="btn--go-to">
<a href="<?= $impact->url() ?>"><?= svg('assets/icons/arrow-left.svg') ?></a>
</button>
<a class="link-block" href="<?= $impact->url() ?>" aria-hidden="true"></a>
</div>
<?php endforeach ?>
</aside>
<?php endif ?>
</main> </main>

View file

@ -33,13 +33,13 @@ $dateLocale = substr(is_array($locale) ? reset($locale) : $locale, 0, 5);
</header> </header>
<div class="page__content">
<?php if ($page->body()->isNotEmpty()): ?> <?php if ($page->body()->isNotEmpty()): ?>
<div class="page__content">
<?= $page->body()->toBlocks() ?> <?= $page->body()->toBlocks() ?>
</div>
<?php endif ?> <?php endif ?>
</div>
<?php $investigations = $page->linkedInvestigations()->toPages() ?> <?php $investigations = $page->linkedInvestigations()->toPages() ?>
<?php if ($investigations->isNotEmpty()): ?> <?php if ($investigations->isNotEmpty()): ?>
@ -76,6 +76,43 @@ $dateLocale = substr(is_array($locale) ? reset($locale) : $locale, 0, 5);
</aside> </aside>
<?php endif ?> <?php endif ?>
<?php
$latestNews = site()->find('news')
->children()->listed()->not($page)
->sortBy('created', 'desc')
->limit(5);
?>
<?php if ($latestNews->isNotEmpty()): ?>
<aside class="page__aside" id="latest-news">
<h3 class="aside__title">Voir aussi</h3>
<?php foreach ($latestNews as $newsItem): ?>
<div class="card--block-small has-link">
<div class="group-top">
<p class="type"><?= t('news.type') ?></p>
<?php if ($newsItem->category()->isNotEmpty()): ?>
<p class="category"><?= $newsItem->category()->esc() ?></p>
<?php endif ?>
</div>
<h4 class="title"><?= $newsItem->title()->esc() ?></h4>
<?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 ?>
<button class="btn--go-to">
<a href="<?= $newsItem->url() ?>"><?= svg('assets/icons/arrow-left.svg') ?></a>
</button>
<a class="link-block" href="<?= $newsItem->url() ?>" aria-hidden="true"></a>
</div>
<?php endforeach ?>
</aside>
<?php endif ?>
</main> </main>