Update index.php

This commit is contained in:
deepend-tildeclub 2024-08-17 08:50:57 -06:00 committed by GitHub
parent c115370510
commit 4cc538c1be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -21,6 +21,7 @@
// Determine the year filter if present // Determine the year filter if present
$selectedYear = isset($_GET['year']) ? $_GET['year'] : null; $selectedYear = isset($_GET['year']) ? $_GET['year'] : null;
$filteredNews = []; $filteredNews = [];
$currentDate = new DateTime();
if ($selectedYear) { if ($selectedYear) {
// Filter news by selected year // Filter news by selected year
@ -31,7 +32,14 @@
} }
} else { } else {
// Show only the most recent 2 news items if no year filter is applied // Show only the most recent 2 news items if no year filter is applied
$filteredNews = array_slice($news, 0, 2); foreach ($news as $newsItem) {
if (new DateTime($newsItem['date']) <= $currentDate) {
$filteredNews[] = $newsItem;
}
if (count($filteredNews) >= 2) {
break;
}
}
} }
// Display news items // Display news items
@ -73,6 +81,7 @@
?> ?>
</div> </div>
<div class="col"> <div class="col">
<p> <p>
tilde.club is not a social network it is one tiny totally tilde.club is not a social network it is one tiny totally