migration for news table in database, news now read from database

This commit is contained in:
2026-04-24 16:33:03 +02:00
parent c9040b2f4e
commit ffe81cdf88
2 changed files with 60 additions and 6 deletions

View File

@@ -34,6 +34,11 @@ if (!$municipality) {
exit;
}
// Loads News for Sidebar
$stmt = $pdo->prepare("SELECT * FROM news WHERE municipality_id = :mid ORDER BY published_at DESC LIMIT 10");
$stmt->execute([':mid' => $municipality['municipality_id']]);
$news_items = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="de">
@@ -207,12 +212,17 @@ if (!$municipality) {
<span class="leaflet-sidebar-close"><i class="fa-solid fa-xmark"></i></span>
</h2>
<div class="sidebar-body">
<div class="news-item">
<span class="news-date">April 2026</span>
<h3>Portal gestartet</h3>
<p>Das Bürgerbeteiligungsportal für <?= htmlspecialchars($municipality['name']) ?> ist online. Wir freuen uns auf Ihre Hinweise und Vorschläge!</p>
</div>
<!-- News Items can be added or loaded from Database here -->
<?php if (empty($news_items)): ?>
<p style="text-align:center;color:#999;padding:20px;">Noch keine Neuigkeiten veröffentlicht.</p>
<?php else: ?>
<?php foreach ($news_items as $news): ?>
<div class="news-item">
<span class="news-date"><?= date('d.m.Y', strtotime($news['published_at'])) ?></span>
<h3><?= htmlspecialchars($news['title']) ?></h3>
<p><?= nl2br(htmlspecialchars($news['content'])) ?></p>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>