feat: add DWZ-Liste template with data fetching, sorting, and rendering functionality
This commit is contained in:
+247
-187
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,15 @@
|
|||||||
Title: DWZ
|
Title: DWZ-Liste
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
HeroText: Hier finden Sie die aktuelle DWZ-Liste unseres Vereins.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
HeroButton: DWZ beim DSB
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
ButtonLink: https://www.schachbund.de/verein/25318.html
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
// Daten abrufen und deserialisieren
|
||||||
|
$url = 'https://www.schachbund.de/php/dewis/verein.php?zps=25318&format=array';
|
||||||
|
$data = @file_get_contents($url);
|
||||||
|
$players = $data ? @unserialize($data) : [];
|
||||||
|
|
||||||
|
function safe($val) {
|
||||||
|
return $val === null || $val === false || $val === '' || $val === 'N' ? '-' : htmlspecialchars($val);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nach DWZ absteigend sortieren
|
||||||
|
if ($players && is_array($players)) {
|
||||||
|
usort($players, function($a, $b) {
|
||||||
|
$dwzA = isset($a['dwz']) && is_numeric($a['dwz']) ? (int)$a['dwz'] : 0;
|
||||||
|
$dwzB = isset($b['dwz']) && is_numeric($b['dwz']) ? (int)$b['dwz'] : 0;
|
||||||
|
return $dwzB <=> $dwzA;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<section class="py-24 bg-sf_grau-50">
|
||||||
|
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||||
|
<table class="min-w-full border border-sf_blau-200 rounded-xl overflow-hidden">
|
||||||
|
<thead class="bg-sf_blau-600 text-white font-bold">
|
||||||
|
<tr>
|
||||||
|
<th class="px-3 py-2">Platz</th>
|
||||||
|
<th class="px-3 py-2">Mitgl.</th>
|
||||||
|
<th class="px-3 py-2">Titel</th>
|
||||||
|
<th class="px-3 py-2">Name</th>
|
||||||
|
<th class="px-3 py-2">DWZ</th>
|
||||||
|
<th class="px-3 py-2">ELO</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php if ($players && is_array($players)): ?>
|
||||||
|
<?php $platz = 1; foreach ($players as $p): ?>
|
||||||
|
<tr class="even:bg-sf_grau-100 odd:bg-white">
|
||||||
|
<td class="px-3 py-2 text-center"><?php echo $platz++; ?></td>
|
||||||
|
<td class="px-3 py-2 text-center"><?php echo safe($p['mglnr']); ?></td>
|
||||||
|
<td class="px-3 py-2 text-center"><?php echo safe($p['titel']); ?></td>
|
||||||
|
<td class="px-3 py-2 font-semibold text-xl text-sf_blau-500 hover:text-sf_gelb-300">
|
||||||
|
<a href="http://www.schachbund.de/spieler.html?pkz=<?php echo safe($p['id']); ?>" target="_blank">
|
||||||
|
<?php echo safe($p['nachname'] . ', ' . $p['vorname']); ?></td>
|
||||||
|
</a>
|
||||||
|
<td class="px-3 py-2 text-right text-xl"><?php echo safe($p['dwz']); ?>-<?php echo safe($p['dwzindex']); ?></td>
|
||||||
|
<td class="px-3 py-2 text-right text-xl"><?php echo safe($p['fideelo']); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<tr><td colspan="6" class="px-3 py-4 text-center text-red-500">Keine Daten verfügbar.</td></tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<section class="bg-sf_blau-500 py-24" id="titel">
|
||||||
|
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||||
|
<div class="grid grid-cols-1 lg:gap-12 lg:grid lg:grid-cols-2 text-red-50">
|
||||||
|
<div class="w-full max-w-lg">
|
||||||
|
<h1 class="text-6xl font-bold"><?= $page->title() ?></h1>
|
||||||
|
</div>
|
||||||
|
<div class="w-full max-w-lg">
|
||||||
|
<p class="lg:pt-0 pt-6 text-xl"><?= $page->heroText() ?></p>
|
||||||
|
<div class="mt-6 flex flex-wrap gap-4 md:mt-8"> <a href="<?= $page->buttonLink() ?>" class="hover:cursor-pointer hover:text-sf_gelb-500" target="_blank"><button class="rounded-button inline-flex gap-3 items-center justify-center whitespace-nowrap transition-all duration-200 ease-in-out disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none border border-border-primary text-text-primary bg-background-primary px-6 py-3" title="Kontakt" type="button"><?= $page->heroButton() ?></button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Templates render the content of your pages.
|
||||||
|
|
||||||
|
They contain the markup together with some control structures
|
||||||
|
like loops or if-statements. The `$page` variable always
|
||||||
|
refers to the currently active page.
|
||||||
|
|
||||||
|
To fetch the content from each field we call the field name as a
|
||||||
|
method on the `$page` object, e.g. `$page->title()`.
|
||||||
|
|
||||||
|
This default template must not be removed. It is used whenever Kirby
|
||||||
|
cannot find a template with the name of the content file.
|
||||||
|
|
||||||
|
Snippets like the header and footer contain markup used in
|
||||||
|
multiple templates. They also help to keep templates clean.
|
||||||
|
|
||||||
|
More about templates: https://getkirby.com/docs/guide/templates/basics
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php snippet('header') ?>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php snippet('navbar') ?>
|
||||||
|
|
||||||
|
<?php snippet('titel') ?>
|
||||||
|
|
||||||
|
<?php snippet('dwz') ?>
|
||||||
|
|
||||||
|
<?= js('assets/js/navbar.js') ?>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<?php snippet('footer') ?>
|
||||||
Reference in New Issue
Block a user