This commit is contained in:
Jürgen Mummert
2025-12-27 20:16:52 +01:00
parent cfffdf2323
commit 131e24fe2e
2 changed files with 25 additions and 3 deletions
@@ -90,7 +90,7 @@ Contao 5 Frontend Module Template
cropLength: 50, cropLength: 50,
cropMarker: '…', cropMarker: '…',
sort: ['priority:desc'] sort: ['startDate:asc', 'priority:desc']
}); });
renderResults(response.hits); renderResults(response.hits);
+23 -1
View File
@@ -83,6 +83,7 @@ class MeilisearchIndexService
], ],
'sortableAttributes' => [ 'sortableAttributes' => [
'priority', 'priority',
'startDate',
], ],
]); ]);
} }
@@ -94,11 +95,25 @@ class MeilisearchIndexService
return; return;
} }
$indexPastEvents = (bool) Config::get('meilisearch_index_past_events');
$today = strtotime('today');
$documents = []; $documents = [];
foreach ($rows as $row) { foreach ($rows as $row) {
$type = $this->detectTypeFromMeta($row['meta'] ?? null); $type = $this->detectTypeFromMeta($row['meta'] ?? null);
// 🛑 VERGANGENE EVENTS FILTERN
if ($type === 'event' && !$indexPastEvents) {
if (!empty($row['startDate'])) {
$eventStart = (int) $row['startDate'];
if ($eventStart < $today) {
continue; // ⛔ Event überspringen
}
}
}
$doc = [ $doc = [
'id' => $type . '_' . $row['id'], 'id' => $type . '_' . $row['id'],
'type' => $type, 'type' => $type,
@@ -111,7 +126,12 @@ class MeilisearchIndexService
'priority' => (int) ($row['priority'] ?? 0), 'priority' => (int) ($row['priority'] ?? 0),
]; ];
// ✅ Bild aus UUID erzeugen (falls vorhanden) // 📅 startDate nur für Events übernehmen
if ($type === 'event' && !empty($row['startDate'])) {
$doc['startDate'] = (int) $row['startDate'];
}
// 🖼️ Bild aus UUID erzeugen
if (!empty($row['imagepath'])) { if (!empty($row['imagepath'])) {
$imagePath = $this->imageHelper->resolveImagePath($row['imagepath']); $imagePath = $this->imageHelper->resolveImagePath($row['imagepath']);
if ($imagePath !== null) { if ($imagePath !== null) {
@@ -122,8 +142,10 @@ class MeilisearchIndexService
$documents[] = $doc; $documents[] = $doc;
} }
if ($documents !== []) {
$index->addDocuments($documents); $index->addDocuments($documents);
} }
}
private function indexTlSearchPdf(Indexes $index): void private function indexTlSearchPdf(Indexes $index): void
{ {