Lehrplan: Country-Default überall AT, übergreifend land-agnostisch

Auftrag von Thomas: Default-Filter überall auf Österreich, andere
Länder weiterhin wählbar.

Modul-Detailseiten (gemeinsamer Partial):
- Filter-Chip mit data-country=Country::current() bekommt Klasse
  active server-seitig (statt "🌐 Alle Länder")
- Country.php in Partial eingebunden
- JS-Filter-Logik überarbeitet: bei konkretem Land werden NUR
  anchor_type='fach' Anker streng nach Land gefiltert; übergreifende
  Themen und andere Fächer bleiben sichtbar (sind primär aus dem
  AT-Lehrplan abgeleitet, didaktisch land-agnostisch nutzbar)
- applyFilter() wird beim Page-Load mit dem aktiven Chip ausgeführt

Lehrplan.php:
- gleiche Filter-Logik gespiegelt (war vorher streng auch für
  übergreifend/andere_fach)
- Default war schon Country::current(), bleibt unverändert

Verifiziert: alle 10 aktiven modul-*.php-Seiten zeigen AT als
Default-active, Lehrplan-Seite ebenfalls.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-04 02:16:04 +02:00
parent 306ec97cb5
commit 95e19818fd
3 changed files with 61 additions and 16 deletions
+38 -9
View File
@@ -27,6 +27,7 @@ if (!isset($MODULE_ID) || !is_string($MODULE_ID)) {
require_once __DIR__ . '/../../php/config/app.php';
require_once __DIR__ . '/../../php/config/db.php';
require_once __DIR__ . '/../../php/lib/EasyLang.php';
require_once __DIR__ . '/../../php/lib/Country.php';
$db = getDB();
@@ -108,6 +109,9 @@ $countryMeta = [
'CH' => ['flag' => '🇨🇭', 'label' => 'Schweiz'],
'LI' => ['flag' => '🇱🇮', 'label' => 'Liechtenstein'],
];
// Default-Land aus Kaskade Session/Cookie/AT — als initialer Anker-Filter aktiv
$qCountry = Country::current();
?><!DOCTYPE html>
<html lang="de">
<head>
@@ -578,9 +582,9 @@ $countryMeta = [
</p>
<div class="md-lehrplan-filters" id="md-filter-row">
<button type="button" class="md-chip active" data-country="">🌐 Alle Länder</button>
<button type="button" class="md-chip<?= $qCountry === '' ? ' active' : '' ?>" data-country="">🌐 Alle Länder</button>
<?php foreach ($countryMeta as $c => $info): ?>
<button type="button" class="md-chip" data-country="<?= esc($c) ?>">
<button type="button" class="md-chip<?= $qCountry === $c ? ' active' : '' ?>" data-country="<?= esc($c) ?>">
<?= $info['flag'] ?> <?= esc($info['label']) ?>
</button>
<?php endforeach; ?>
@@ -679,22 +683,47 @@ $countryMeta = [
</footer>
<script>
// Länder-Filter für Lehrplan-Anker — übergreifende Themen + andere Fächer bleiben sichtbar (Land-agnostisch)
// Länder-Filter für Lehrplan-Anker. Default ist das aktuell gewählte Land
// (über Country-Helper aus Session/Cookie, Standardwert AT).
//
// Logik:
// - Bei einem konkreten Land (AT/DE/CH/LI):
// • anchor_type='fach' wird nach Land gefiltert (nur passende sichtbar)
// • anchor_type='uebergreifendes_thema' und 'anderes_fach' bleiben
// immer sichtbar — sie sind primär aus dem AT-Lehrplan abgeleitet,
// aber didaktisch land-agnostisch nutzbar
// - "🌐 Alle Länder": alles sichtbar
(function () {
const filterRow = document.getElementById('md-filter-row');
if (!filterRow) return;
function applyFilter(country) {
document.querySelectorAll('.md-anchor').forEach(a => {
const type = a.dataset.anchorType;
const aCountry = a.dataset.country;
let hide = false;
if (country) {
// Konkretes Land gewählt: Fach-Anker streng filtern,
// übergreifende + andere Fächer immer zeigen.
if (type === 'fach') {
hide = aCountry !== country;
}
}
a.classList.toggle('hidden', hide);
});
}
filterRow.addEventListener('click', (e) => {
const btn = e.target.closest('.md-chip');
if (!btn) return;
filterRow.querySelectorAll('.md-chip').forEach(c => c.classList.remove('active'));
btn.classList.add('active');
const country = btn.dataset.country;
document.querySelectorAll('.md-anchor').forEach(a => {
// Anker mit einem Land: nur zeigen wenn passt. Anker ohne Land oder mit allen Laendern: immer zeigen.
const hide = country && a.dataset.country && a.dataset.country !== country;
a.classList.toggle('hidden', !!hide);
});
applyFilter(btn.dataset.country);
});
// Initial-Filter anwenden (für den server-seitig vor-gewählten Default)
const activeChip = filterRow.querySelector('.md-chip.active');
if (activeChip) applyFilter(activeChip.dataset.country);
})();
</script>