mémorisation catégorie par cookie, URLs propres /categorie/
This commit is contained in:
+22
-10
@@ -1195,36 +1195,48 @@ footer.mt-5 { margin-top: 0 !important; }
|
|||||||
.tag-cloud {
|
.tag-cloud {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: .4rem .7rem;
|
gap: .5rem;
|
||||||
align-items: baseline;
|
align-items: center;
|
||||||
padding: 1rem 0;
|
padding: 1.25rem 0;
|
||||||
border-top: 1px solid var(--vl-border, #e5e7eb);
|
border-top: 1px solid var(--vl-border, #e5e7eb);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-cloud-item {
|
.tag-cloud-item {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: .3em;
|
||||||
|
padding: .25em .75em;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: 1px solid var(--vl-border, #e5e7eb);
|
||||||
|
background: transparent;
|
||||||
color: var(--vl-muted);
|
color: var(--vl-muted);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
transition: color .15s;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
transition: background .15s, color .15s, border-color .15s;
|
||||||
|
font-size: .85rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-cloud-item:hover,
|
.tag-cloud-item:hover {
|
||||||
.tag-cloud-item.active {
|
background: var(--vl-accent);
|
||||||
color: var(--vl-accent);
|
border-color: var(--vl-accent);
|
||||||
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-cloud-item.active {
|
.tag-cloud-item.active {
|
||||||
|
background: var(--vl-accent);
|
||||||
|
border-color: var(--vl-accent);
|
||||||
|
color: #fff;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-count {
|
.tag-count {
|
||||||
font-size: .65em;
|
font-size: .8em;
|
||||||
opacity: .6;
|
opacity: .7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-cloud-reset {
|
.tag-cloud-reset {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
font-size: .85em;
|
font-size: .85rem;
|
||||||
color: var(--vl-muted);
|
color: var(--vl-muted);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-1
@@ -1770,7 +1770,29 @@ switch ($action) {
|
|||||||
default:
|
default:
|
||||||
$privateCats = $articles->getPrivateCategories();
|
$privateCats = $articles->getPrivateCategories();
|
||||||
$allCats = $articles->getCategories();
|
$allCats = $articles->getCategories();
|
||||||
$filterCat = trim($_GET['cat'] ?? '');
|
|
||||||
|
if (array_key_exists('cat', $_GET)) {
|
||||||
|
$filterCat = trim($_GET['cat']);
|
||||||
|
if ($filterCat === '') {
|
||||||
|
// Réinitialisation explicite → effacer le cookie et rediriger
|
||||||
|
setcookie('varlog_cat', '', time() - 3600, '/', '', $isHttps, true);
|
||||||
|
header('Location: /', true, 302);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
// Sauvegarder la catégorie choisie (1 an)
|
||||||
|
setcookie('varlog_cat', $filterCat, time() + 365 * 24 * 3600, '/', '', $isHttps, true);
|
||||||
|
} else {
|
||||||
|
// Pas de paramètre → appliquer le cookie si la catégorie existe toujours
|
||||||
|
$savedCat = trim($_COOKIE['varlog_cat'] ?? '');
|
||||||
|
if ($savedCat !== '' && isset($allCats[$savedCat])) {
|
||||||
|
header('Location: /categorie/' . rawurlencode($savedCat), true, 302);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
if ($savedCat !== '' && !isset($allCats[$savedCat])) {
|
||||||
|
setcookie('varlog_cat', '', time() - 3600, '/', '', $isHttps, true);
|
||||||
|
}
|
||||||
|
$filterCat = '';
|
||||||
|
}
|
||||||
$allPosts = array_values(array_filter($articles->getAll(), static function (array $a) use ($privateCats, $filterCat): bool {
|
$allPosts = array_values(array_filter($articles->getAll(), static function (array $a) use ($privateCats, $filterCat): bool {
|
||||||
if (!$a['published']) {
|
if (!$a['published']) {
|
||||||
return canDoOnArticle('view_drafts', $a);
|
return canDoOnArticle('view_drafts', $a);
|
||||||
|
|||||||
@@ -113,15 +113,14 @@ if (!empty($_tagCats)):
|
|||||||
: round(0.8 + ($_catCount - $_minCount) / ($_maxCount - $_minCount) * 0.9, 2);
|
: round(0.8 + ($_catCount - $_minCount) / ($_maxCount - $_minCount) * 0.9, 2);
|
||||||
$_active = ($filterCat === $_catName);
|
$_active = ($filterCat === $_catName);
|
||||||
?>
|
?>
|
||||||
<a href="/?cat=<?= rawurlencode($_catName) ?>"
|
<a href="/categorie/<?= rawurlencode($_catName) ?>"
|
||||||
class="tag-cloud-item<?= $_active ? ' active' : '' ?>"
|
class="tag-cloud-item<?= $_active ? ' active' : '' ?>">
|
||||||
style="font-size:<?= $_size ?>em">
|
|
||||||
<?= htmlspecialchars($_catName) ?>
|
<?= htmlspecialchars($_catName) ?>
|
||||||
<sup class="tag-count"><?= $_catCount ?></sup>
|
<span class="tag-count"><?= $_catCount ?></span>
|
||||||
</a>
|
</a>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php if ($filterCat !== ''): ?>
|
<?php if ($filterCat !== ''): ?>
|
||||||
<a href="/" class="tag-cloud-reset">× tout afficher</a>
|
<a href="/?cat=" class="tag-cloud-reset">× tout afficher</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</nav>
|
</nav>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user