diff --git a/index.php b/index.php
index be5a465..ceefb62 100644
--- a/index.php
+++ b/index.php
@@ -13,34 +13,66 @@
= new DateTime($newsItem['date'])) {
- echo '
' . htmlspecialchars($newsItem['title']) . ':
';
- echo '' . htmlspecialchars($newsItem['heading']) . '
';
- echo '' . htmlspecialchars($newsItem['content']) . '
';
+ // Sort news items by date, most recent first
+ usort($news, function ($a, $b) {
+ return strtotime($b['date']) - strtotime($a['date']);
+ });
- if (isset($newsItem['details']) && is_array($newsItem['details'])) {
- echo '';
- foreach ($newsItem['details'] as $detail) {
- echo '- ' . htmlspecialchars($detail) . '
';
- }
- echo '
';
+ // Determine the year filter if present
+ $selectedYear = isset($_GET['year']) ? $_GET['year'] : null;
+ $filteredNews = [];
+
+ if ($selectedYear) {
+ // Filter news by selected year
+ foreach ($news as $newsItem) {
+ if (date('Y', strtotime($newsItem['date'])) == $selectedYear) {
+ $filteredNews[] = $newsItem;
}
-
- if (isset($newsItem['note'])) {
- echo '' . htmlspecialchars($newsItem['note']) . '
';
- }
-
- if (isset($newsItem['additional_content'])) {
- echo '' . htmlspecialchars($newsItem['additional_content']) . '
';
- }
-
- echo '
';
}
+ } else {
+ // Show only the most recent 2 news items if no year filter is applied
+ $filteredNews = array_slice($news, 0, 2);
}
+
+ // Display news items
+ foreach ($filteredNews as $newsItem) {
+ echo '' . htmlspecialchars($newsItem['title']) . ':
';
+ echo '' . htmlspecialchars($newsItem['heading']) . '
';
+ echo '' . htmlspecialchars($newsItem['content']) . '
';
+
+ if (isset($newsItem['details']) && is_array($newsItem['details'])) {
+ echo '';
+ foreach ($newsItem['details'] as $detail) {
+ echo '- ' . htmlspecialchars($detail) . '
';
+ }
+ echo '
';
+ }
+
+ if (isset($newsItem['note'])) {
+ echo '' . htmlspecialchars($newsItem['note']) . '
';
+ }
+
+ if (isset($newsItem['additional_content'])) {
+ echo '' . htmlspecialchars($newsItem['additional_content']) . '
';
+ }
+
+ echo '
';
+ }
+
+ // Display year links for filtering
+ $years = array_unique(array_map(function ($newsItem) {
+ return date('Y', strtotime($newsItem['date']));
+ }, $news));
+ sort($years);
+
+ echo 'View news by year: ';
+ foreach ($years as $year) {
+ echo '
' . $year . ' ';
+ }
+ echo '
';
?>
-
+
tilde.club is not a social network it is one tiny totally