index-main/site/templates/news.php

82 lines
2.7 KiB
PHP
Raw Normal View History

2026-02-25 15:22:34 +01:00
<?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>
<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">
2026-02-25 15:36:44 +01:00
<button class="dropdown__trigger sort btn--small no-link"><span class="icon"><?= svg('assets/icons/filter.svg') ?></span><p>Catégories</p></button>
2026-02-25 15:22:34 +01:00
<div class="dropdown__content">
<ul>
<?php foreach (page('database')->newsCategories()->split() as $cat): ?>
<li><button type="button" data-filter="<?= esc(Str::slug($cat)) ?>"><?= esc($cat) ?></button></li>
<?php endforeach ?>
</ul>
</div>
</div>
</div>
<div class="page__content grid-masonry">
<div class="grid-sizer"></div>
<?php foreach ($page->children()->listed()->sortBy('created', 'desc') as $newsItem): ?>
<?php
$categories = $newsItem->category()->split();
$category = $categories[0] ?? '';
$cover = $newsItem->cover()->toFile();
$investigations = $newsItem->linkedInvestigations()->toPages();
?>
<div class="card--block has-link" data-news-type="<?= esc(Str::slug($category)) ?>">
<?php if ($cover): ?>
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
<?php endif ?>
<div class="group-top">
<p class="type"><?= t('news.type') ?></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"><?= $newsItem->created()->toDate('d MMMM yyyy', $dateLocale) ?></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="<?= $newsItem->url() ?>"></a>
</div>
<?php endforeach ?>
</div>
</main>
<?php snippet('footer') ?>