diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php index e14bd7e..1410e08 100644 --- a/php/controller/showCategory-controller.php +++ b/php/controller/showCategory-controller.php @@ -1,21 +1,41 @@ getArticlesByCategory($category); + + $allArticles = $articleManager->getArticlesByCategory($category); + + // Paginierung konfigurieren + $limit = 10; // Wie viele Artikel pro Seite? + $totalArticles = count($allArticles); + $totalPages = ceil($totalArticles / $limit); + + if ($page > $totalPages && $totalPages > 0) { $page = $totalPages; } + + $offset = ($page - 1) * $limit; + $articles = array_slice($allArticles, $offset, $limit); + } catch (Exception $e) { $_SESSION["message"] = "internal_error"; include_once "content/404.php"; exit(); } -}else{ +} else { $_SESSION["message"] = "invalid_category"; include_once "content/404.php"; exit(); } -?> \ No newline at end of file +?>