tfe: redirect internal metadata links from /repertoire to /search

redirect internal metadata links from /repertoire to /search, add query param for search bar prefill, fix filter visibility on desktop

 redirect metadata links from /repertoire to /search, prefill search bar, fix filter visibility

 link metadata to /search, preserve keyword filter in form, show active keyword chip
This commit is contained in:
Pontoporeia
2026-07-10 14:16:36 +02:00
parent f5a7d70fbc
commit f427352a71
4 changed files with 63 additions and 8 deletions
+24 -2
View File
@@ -4,14 +4,14 @@
<?php
// Count active filters (excluding 'query' and 'page')
$filterKeys = ['year', 'ap_program', 'orientation', 'finality', 'format'];
$filterKeys = ['year', 'ap_program', 'orientation', 'finality', 'format', 'keyword'];
$activeFilterCount = 0;
foreach ($filterKeys as $k) {
if (!empty($_GET[$k])) $activeFilterCount++;
}
?>
<!-- Filter controls -->
<details class="search-filters-toggle">
<details class="search-filters-toggle" open>
<summary class="search-filters-summary">
Filtres
<?php if ($activeFilterCount > 0): ?>
@@ -20,6 +20,12 @@ foreach ($filterKeys as $k) {
</summary>
<form class="search-controls" method="GET" action="/search">
<input type="hidden" name="query" value="<?= htmlspecialchars($_GET['query'] ?? '') ?>">
<?php if (!empty($_GET['keyword'])): ?>
<input type="hidden" name="keyword" value="<?= htmlspecialchars($_GET['keyword']) ?>">
<span class="search-active-keyword">Mot-clé&nbsp;: <strong><?= htmlspecialchars($_GET['keyword']) ?></strong>
<a href="/search?query=<?= urlencode($_GET['query'] ?? '') ?>" class="search-keyword-remove" aria-label="Retirer le filtre mot-clé">×</a>
</span>
<?php endif; ?>
<label class="search-filter-label" for="filter-year">Année
<select class="search-filter-select" name="year" id="filter-year">
@@ -88,3 +94,19 @@ foreach ($filterKeys as $k) {
<main class="search-main" id="main-content">
<?php include APP_ROOT . '/templates/partials/search-results.php'; ?>
</main>
<script>
// Close filter <details> on mobile by default when no filters active
(function() {
if (window.innerWidth > 768) return;
var params = new URLSearchParams(window.location.search);
var hasActive = false;
params.forEach(function(v, k) {
if (k === 'page' || k === 'query') return;
if (v !== '') hasActive = true;
});
if (hasActive) return;
var toggle = document.querySelector('.search-filters-toggle');
if (toggle) toggle.removeAttribute('open');
})();
</script>