From 06feb93095ea0309ef36fc644cd94b66d39909ba Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 22 Feb 2024 09:42:37 +0100 Subject: [PATCH] Add article page --- lib/newsarticle.php | 20 +++++++++++++++++ pages/news/index.html | 8 ------- pages/news/index.php | 43 +++++++++++++++++++++++++++++++++++++ templates/newsArticles.html | 6 ++++++ 4 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 lib/newsarticle.php delete mode 100644 pages/news/index.html create mode 100644 pages/news/index.php create mode 100644 templates/newsArticles.html diff --git a/lib/newsarticle.php b/lib/newsarticle.php new file mode 100644 index 0000000..2289a24 --- /dev/null +++ b/lib/newsarticle.php @@ -0,0 +1,20 @@ +query("SELECT NewsArticles.ID, NewsArticles.WrittenAt, NewsArticles.WrittenBy, NewsArticles.Title, NewsArticles.Body, NewsArticles.FileList Users.Nickname FROM NewsArticles INNER JOIN Users ON NewsArticles.WrittenBy = Users.ID; "); + + // Check if the query executed Successfully + if ($result) { + while ($row = $result->fetch_assoc()) { + $articles[] = $row; + } + } + } + + return $articles; +} \ No newline at end of file diff --git a/pages/news/index.html b/pages/news/index.html deleted file mode 100644 index 34116ae..0000000 --- a/pages/news/index.html +++ /dev/null @@ -1,8 +0,0 @@ - -
-

-

Adlerka študentské news

-
-

Rohová časť stola v a A103 spáchala samovraždu po dotyku Richarda Mikloša!!!

-
- diff --git a/pages/news/index.php b/pages/news/index.php new file mode 100644 index 0000000..528549a --- /dev/null +++ b/pages/news/index.php @@ -0,0 +1,43 @@ + +

$articleTitle

+
+

$articleWrittenByName

+

$articleWrittenAt

+
+
+$articleBody +
+"; +} + +$output = str_replace("__TEMPLATE__ARTICLES_HERE__", $articles_out, $output); + +return [ + "output" => $output, + "parameters" => + [ + "minimal_permission_level" => 2, + "secret" => "no", + "page_title" => "Novinky" + ] +]; diff --git a/templates/newsArticles.html b/templates/newsArticles.html new file mode 100644 index 0000000..8645f78 --- /dev/null +++ b/templates/newsArticles.html @@ -0,0 +1,6 @@ +
+

+

Adlerka študentské news

+
+ __TEMPLATE__ARTICLES_HERE__ +