mirror of https://github.com/tildeclub/site.git
Update index.php
This commit is contained in:
parent
c115370510
commit
4cc538c1be
11
index.php
11
index.php
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue