diff --git a/content/home.php b/content/home.php
index 58e0993..878295a 100644
--- a/content/home.php
+++ b/content/home.php
@@ -17,6 +17,11 @@ include_once 'php/controller/home-controller.php';
Dein Beitrag wurde erfolgreich veröffentlicht!
+
+
+ Diese Kategorie ist nicht gültig.
+
+
diff --git a/content/showCategory.php b/content/showCategory.php
new file mode 100644
index 0000000..e07c14f
--- /dev/null
+++ b/content/showCategory.php
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Es sind noch keine Beiträge in dieser Kategorie enthalten.
+
+
+
+
\ No newline at end of file
diff --git a/includes/navbar.php b/includes/navbar.php
index b233584..2beb981 100644
--- a/includes/navbar.php
+++ b/includes/navbar.php
@@ -39,50 +39,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
Sprachen
MINT
Gesellschaft & Werte
Technik & Praxis
@@ -92,50 +92,50 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
Sprachen
MINT
Gesellschaft & Werte
Technik & Praxis
diff --git a/php/controller/showCategory-controller.php b/php/controller/showCategory-controller.php
new file mode 100644
index 0000000..59dda14
--- /dev/null
+++ b/php/controller/showCategory-controller.php
@@ -0,0 +1,20 @@
+getArticlesByCategory($category);
+ } catch (Exception $e) {
+ $_SESSION["message"] = "internal_error";
+ header("location: ../../index.php");
+ exit();
+ }
+}else{
+ $_SESSION["message"] = "invalid_category";
+ header("location: ../../index.php");
+ exit();
+}
+?>
\ No newline at end of file
diff --git a/php/model/ArticleManager.php b/php/model/ArticleManager.php
index 5887cc5..45325e0 100644
--- a/php/model/ArticleManager.php
+++ b/php/model/ArticleManager.php
@@ -44,5 +44,26 @@ class ArticleManager extends LocalArticleManager
return $articleManager;
}
+
+ public function getArticlesByCategory($category)
+ {
+ $articles = $this->getAllArticles();
+ $filteredArticles = [];
+
+ foreach ($articles as $article) {
+ if (isset($article['category']) && $article['category'] == $category) {
+ $filteredArticles[] = new Article(
+ intval($article['id']),
+ $article['title'],
+ $article['content'],
+ $article['author'],
+ $article['category'],
+ $article['tags'],
+ $article['creationDate']
+ );
+ }
+ }
+ return $filteredArticles;
+ }
}
\ No newline at end of file
diff --git a/php/model/ArticleManagerDAO.php b/php/model/ArticleManagerDAO.php
index 191b21a..d33df23 100644
--- a/php/model/ArticleManagerDAO.php
+++ b/php/model/ArticleManagerDAO.php
@@ -85,6 +85,13 @@ interface ArticleManagerDAO
*/
public function search(string $keyword): array;
+ /**
+ * Gibt alle Beiträge einer gegebenen Kategorie aus.
+ * @param $category
+ * @return mixed
+ */
+ public function getArticlesByCategory($category);
+
}
?>
\ No newline at end of file