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
$selectedYear = isset($_GET['year']) ? $_GET['year'] : null;
$filteredNews = [];
$currentDate = new DateTime();
if ($selectedYear) {
// Filter news by selected year
@ -31,7 +32,14 @@
}
} else {
// 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
@ -72,6 +80,7 @@
echo '</div>';
?>
</div>
<div class="col">
<p>