ajout d'une fonction pour faire dans l'autre sens : avoir toute les date (parent et linked) + implémentation de la fonction

This commit is contained in:
antonin gallon 2026-02-09 22:24:17 +01:00
parent 7501e2cbb7
commit 9789b645ff
7 changed files with 43 additions and 12 deletions

View file

@ -1,5 +1,17 @@
<?php
function allYears ($article) {
$years = new Pages([$article->parent()]);
foreach (site()->find('textes')->children() as $year) {
if ($year->linkedTexts()->toPages()->has($article)) {
$years = $years->add($year);
}
}
return $years;
}
function setTitleFontSizeClass($title, $level = 'h1')
{
$length = strlen($title);

View file

@ -29,9 +29,12 @@
<span class="light">publié le </span><?php echo $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a
href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a>
/ <a
<span class="light">dans</span>
<?php foreach(allYears($article) as $year):?>
<a href="<?= $year->url() ?>"><?= $year->title()?></a>/
<?php endforeach ?>
<a
href="/categories/<?= Str::slug($article->category()) ?>"><?= $article->category() ?></a>
</p>
</div>

View file

@ -49,9 +49,11 @@
<span class="light">publié le </span><?php echo $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a
href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a>
/ <a
<span class="light">dans</span>
<?php foreach(allYears($article) as $year): ?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a
href="/categories/<?= Str::slug($article->category()) ?>"><?= $article->category() ?></a>
</p>
</div>

View file

@ -9,7 +9,11 @@
<span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
<span class="light">dans</span>
<?php foreach(allYears($article) as $year): ?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p>
</div>
</li>

View file

@ -23,7 +23,11 @@
<div class="text__infos">
<p>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
<span class="light">dans</span>
<?php foreach(allYears($article) as $year): ?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p>
</div>
</li>

View file

@ -27,9 +27,11 @@
href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le
</span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a
href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a>
/ <a
<span class="light">dans</span>
<?php foreach(allYears($article) as $year): ?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a
href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p>
</div>

View file

@ -40,7 +40,11 @@
<span class="light">par</span>
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
<span class="light">dans</span>
<?php foreach(allYears($article) as $year):?>
<a href="<?= $year->url() ?>"><?= $year->title() ?></a> /
<?php endforeach ?>
<a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
</p>
</div>
</li>