Add Index Listener
This commit is contained in:
@@ -14,51 +14,50 @@ class MeilisearchPageMarkerListener
|
|||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ✅ Vorhandene Marker (event/news) übernehmen
|
||||||
|
$markers = $GLOBALS['MEILISEARCH_MARKERS'] ?? [];
|
||||||
|
|
||||||
$page = $GLOBALS['objPage'];
|
$page = $GLOBALS['objPage'];
|
||||||
$lines = ['MEILISEARCH'];
|
|
||||||
|
|
||||||
// ======================
|
$priority = (int) ($page->priority ?? 0);
|
||||||
// PAGE
|
$keywords = trim((string) ($page->keywords ?? ''));
|
||||||
// ======================
|
|
||||||
if ((int) $page->priority > 0) {
|
|
||||||
$lines[] = 'page.priority=' . (int) $page->priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($page->keywords)) {
|
// ✅ searchimage: Page → Fallback
|
||||||
$lines[] = 'page.keywords=' . trim($page->keywords);
|
$searchImageUuid = null;
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($page->searchimage)) {
|
if (!empty($page->searchimage)) {
|
||||||
$lines[] = 'page.searchimage=' . StringUtil::binToUuid($page->searchimage);
|
$searchImageUuid = StringUtil::binToUuid($page->searchimage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================
|
if (!$searchImageUuid) {
|
||||||
// EVENT
|
$fallback = Config::get('meilisearch_fallback_image');
|
||||||
// ======================
|
if ($fallback) {
|
||||||
if (!empty($GLOBALS['MEILISEARCH_MARKERS']['event'])) {
|
// tl_settings speichert varbinary(16) → UUID
|
||||||
$event = $GLOBALS['MEILISEARCH_MARKERS']['event'];
|
$searchImageUuid = StringUtil::binToUuid($fallback);
|
||||||
|
|
||||||
if (!empty($event['priority'])) {
|
|
||||||
$lines[] = 'event.priority=' . $event['priority'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($event['keywords'])) {
|
|
||||||
$lines[] = 'event.keywords=' . $event['keywords'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================
|
// ✅ Page-Marker NUR ergänzen, nicht alles überschreiben
|
||||||
// NEWS (später)
|
$markers['page'] = [
|
||||||
// ======================
|
'priority' => $priority > 0 ? $priority : null,
|
||||||
if (!empty($GLOBALS['MEILISEARCH_MARKERS']['news'])) {
|
'keywords' => $keywords !== '' ? $keywords : null,
|
||||||
$news = $GLOBALS['MEILISEARCH_MARKERS']['news'];
|
'searchimage' => $searchImageUuid ?: null,
|
||||||
|
];
|
||||||
|
|
||||||
if (!empty($news['priority'])) {
|
// ✅ Ausgabe bauen
|
||||||
$lines[] = 'news.priority=' . $news['priority'];
|
$lines = ['MEILISEARCH'];
|
||||||
|
|
||||||
|
foreach ($markers as $scope => $data) {
|
||||||
|
if (!is_array($data)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($news['keywords'])) {
|
foreach ($data as $key => $value) {
|
||||||
$lines[] = 'news.keywords=' . $news['keywords'];
|
if ($value === null || $value === '' || $value === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$lines[] = $scope . '.' . $key . '=' . $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +65,10 @@ class MeilisearchPageMarkerListener
|
|||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
$marker = "\n<!--\n" . implode("\n", $lines) . "\n-->\n";
|
$marker =
|
||||||
|
"\n<!--\n" .
|
||||||
|
implode("\n", $lines) .
|
||||||
|
"\n-->\n";
|
||||||
|
|
||||||
return str_replace('</body>', $marker . '</body>', $buffer);
|
return str_replace('</body>', $marker . '</body>', $buffer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user