category.php : don't show year if no article

This commit is contained in:
isUnknown 2024-04-06 11:55:51 +02:00
parent 3804d13cb6
commit b0fb0b101d
8 changed files with 50 additions and 35 deletions

View file

@ -13,8 +13,10 @@
>
<ul>
<?php foreach($kirby->collection('years') as $year): ?>
<?php if ($year) : ?>
<?php endif ?>
<?php if (A::some($year->children()->toArray(), function ($text) use ($page) {
return $text['content']['category'] == $page->title()->value();
})): ?>
<li>
<div
x-data='{
isOpen: false
@ -35,13 +37,20 @@
</div>
<button
:class="isOpen ? 'open' : 'close'"
class="see-more toggle left" @click="isOpen = !isOpen">Lire</button>
class="see-more toggle left" @click="isOpen = !isOpen"
>
Lire
</button>
</div>
<?php foreach($year->children() as $article): ?>
<?php if ($article->category() == $page->title()) : ?>
<?php snippet('text-item', ['article' => $article]) ?>
<?php endif ?>
<?php endforeach ?>
<ul>
<?php foreach($year->children() as $article): ?>
<?php if ($article->category() == $page->title()->value()) : ?>
<?php snippet('text-item', ['article' => $article]) ?>
<?php endif ?>
<?php endforeach ?>
</ul>
</li>
<?php endif ?>
<?php endforeach ?>
</ul>
</div>