62 lines
3.0 KiB
PHP
62 lines
3.0 KiB
PHP
<?php
|
|
include_once "php/controller/showCategory-controller.php";
|
|
?>
|
|
|
|
<div class="category-results-container">
|
|
<!-- Kategorie-Titel sicher ausgeben -->
|
|
<h1>Kategorie: <?php echo (isset($category) && !empty($category)) ? htmlspecialchars($category) : 'Unbekannt'; ?></h1>
|
|
|
|
<!-- 1. Die Artikel-Liste ausgeben -->
|
|
<div class="articles-list">
|
|
<?php if (isset($articles) && !empty($articles)): ?>
|
|
<?php foreach ($articles as $article): ?>
|
|
<article class="article-item">
|
|
<!-- Sichere Objektausrufe über die Getter-Methoden -->
|
|
<h2><?php echo (isset($article) && !empty($article->getTitle())) ? htmlspecialchars($article->getTitle()) : 'Kein Titel'; ?></h2>
|
|
<p><?php echo (isset($article) && !empty($article->getContent())) ? htmlspecialchars($article->getContent()) : 'Kein Inhalt'; ?></p>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<p>Keine Artikel in dieser Kategorie gefunden.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- 2. Der Paginator (Greift nur, wenn mehr als eine Seite existiert) -->
|
|
<?php if (isset($totalPages) && $totalPages > 1): ?>
|
|
<form id="search-form-id" action="index.php" method="GET" style="display: inline;">
|
|
|
|
<!-- Pfad und Kategorie als versteckte Felder mitsenden -->
|
|
<input type="hidden" name="pfad" value="showCategory">
|
|
<input type="hidden" name="category" value="<?php echo (isset($category) && !empty($category)) ? htmlspecialchars($category) : ''; ?>">
|
|
|
|
<!-- Das Feld, das dein JS-Paginator befüllt (Nutzt Kurzform ?? für Fallback) -->
|
|
<input type="hidden" id="s-res-page-input" name="page" value="<?php echo (isset($page) && !empty($page)) ? $page : 1; ?>">
|
|
|
|
<!-- Die Navigations-Buttons -->
|
|
<div class="s-res-page-navigation">
|
|
|
|
<!-- Zurück-Button -->
|
|
<?php $currentPage = $page ?? 1; ?>
|
|
<button type="button" class="s-res-page-btn" data-page="<?php echo $currentPage - 1; ?>" <?php echo ($currentPage <= 1) ? 'disabled' : ''; ?>>
|
|
« Zurück
|
|
</button>
|
|
|
|
<!-- Seitenzahlen generieren -->
|
|
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
|
<button type="button"
|
|
class="s-res-page-btn <?php echo ($i === $currentPage) ? 'active' : ''; ?>"
|
|
data-page="<?php echo $i; ?>"
|
|
<?php echo ($i === $currentPage) ? 'disabled' : ''; ?>>
|
|
<?php echo $i; ?>
|
|
</button>
|
|
<?php endfor; ?>
|
|
|
|
<!-- Vor-Button -->
|
|
<button type="button" class="s-res-page-btn" data-page="<?php echo $currentPage + 1; ?>" <?php echo ($currentPage >= $totalPages) ? 'disabled' : ''; ?>>
|
|
Weiter »
|
|
</button>
|
|
</div>
|
|
</form>
|
|
<?php endif; ?>
|
|
</div>
|