47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
declare(strict_types=1);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Mannschafts-Seite (DRY-Template für 1./2. Herren + Damen). Props:
|
|||
|
|
* $team array — Eintrag aus data/teams.json.
|
|||
|
|
* $slug string — voller Seiten-Slug (für Anker-Links).
|
|||
|
|
* Aufbau: Hero → Team-Bento (Bild, Einleitung, Training, Spielort) → FAQ + Ansprechpartner.
|
|||
|
|
* Leere Datenblöcke (Training, FAQ, fehlender Kontakt) blenden sich selbst aus.
|
|||
|
|
*/
|
|||
|
|
$slug = $slug ?? '';
|
|||
|
|
|
|||
|
|
// Ansprechpartner aus der Single-Source auflösen (ein oder mehrere, Reihenfolge wie angegeben).
|
|||
|
|
$allPersons = json_load('ansprechpartner')['persons'] ?? [];
|
|||
|
|
$wantDept = $team['contact_department'] ?? '';
|
|||
|
|
$wantNames = $team['contact_names'] ?? (isset($team['contact_name']) ? [$team['contact_name']] : []);
|
|||
|
|
$contacts = [];
|
|||
|
|
foreach ($wantNames as $wn) {
|
|||
|
|
foreach ($allPersons as $p) {
|
|||
|
|
if (($p['department'] ?? '') === $wantDept && ($p['name'] ?? '') === $wn) {
|
|||
|
|
$contacts[] = $p;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
component('hero', ['hero' => $team['hero']]);
|
|||
|
|
|
|||
|
|
if (!empty($team['team_photo']['image'])) {
|
|||
|
|
component('team-photo', ['photo' => $team['team_photo'], 'anchor' => 'mannschaftsfoto']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
component('team-bento', ['team' => $team, 'anchor' => 'team-info']);
|
|||
|
|
|
|||
|
|
if (!empty($team['roster']['members']) || !empty($team['roster']['groups'])) {
|
|||
|
|
component('team-roster', ['roster' => $team['roster'], 'anchor' => 'kader']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
component('faq-contact', [
|
|||
|
|
'faq' => $team['faq'] ?? [],
|
|||
|
|
'faqIntro' => 'Die wichtigsten Fragen rund um die ' . ($team['name'] ?? 'Mannschaft') . ' – kurz beantwortet.',
|
|||
|
|
'persons' => $contacts,
|
|||
|
|
'contactTitle' => '',
|
|||
|
|
'anchor' => 'kontakt',
|
|||
|
|
]);
|