aujourd’hui
$manifestations = array_filter($manifestations, function($item) use ($today) {
if (
empty($item['datemanif']) ||
empty($item['finaffichage']) ||
empty($item['imagemanif']) ||
empty($item['categorie'])
) {
return false;
}
$date_fin = $item['finaffichage'];
$image = $item['imagemanif'];
$categorie = strtoupper(trim($item['categorie']));
// ✅ Garde uniquement si finaffichage > aujourd’hui
$valide = ($date_fin > $today);
// Image contient "tonnerre" et catégorie MA
return $valide && stripos($image, 'tonnerre') !== false && $categorie === 'MA';
});
// ✅ Trier par datemanif croissante
usort($manifestations, fn($a, $b) => strcmp($a['datemanif'], $b['datemanif']));
// Limiter à 4 résultats
$manifestations = array_slice($manifestations, 0, 4);
// --- STYLES ---
echo <<
.ltp-image-grid {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
padding: 10px;
}
.ltp-image-grid .ltp-image-item {
flex: 1 1 220px;
max-width: 220px;
}
.ltp-image-grid img {
width: 100%;
height: auto;
aspect-ratio: 220 / 310;
object-fit: cover;
border: 1px solid #ccc;
box-shadow: 2px 2px 6px rgba(0,0,0,0.2);
display: block;
transition: transform 0.2s ease;
}
.ltp-image-grid a:hover img {
transform: scale(1.02);
}
.ltp-image-grid .ltp-titre {
text-align: center;
font-weight: bold;
margin-top: 6px;
white-space: normal;
}
.ltp-image-grid small {
color: #666;
}
@media (max-width: 600px) {
.ltp-image-grid .ltp-image-item {
max-width: 100%;
flex: 1 1 100%;
}
}
HTML;
// --- AFFICHAGE ---
foreach ($manifestations as $m) {
$image = htmlspecialchars($m['imagemanif'] ?? '');
$lieu = $m['lieumanif'] ?? 'Lieu non précisé';
$date1 = $m['datemanif'] ?? '';
$date2 = $m['finaffichage'] ?? '';
if (!$image) continue;
$lieu_html = nl2br(htmlspecialchars($lieu));
// Si datemanif ≠ finaffichage → on affiche finaffichage
$date_affichee = ($date1 !== $date2 && !empty($date2)) ? $date2 : $date1;
$img_url = $image_base_url . rawurlencode($image) . '.webp';
echo "
$lieu_html
$date_affichee
";
}
echo "
";
?>