Bugfix
This commit is contained in:
@@ -18,6 +18,25 @@ class MeilisearchPageMarkerListener
|
|||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* =====================
|
||||||
|
* CONTENT-BILD (TOP PRIORITÄT)
|
||||||
|
* =====================
|
||||||
|
*/
|
||||||
|
$contentImageUuid = null;
|
||||||
|
|
||||||
|
if (preg_match('#<main\b[^>]*>(.*?)</main>#si', $buffer, $m)) {
|
||||||
|
$mainHtml = $m[1];
|
||||||
|
|
||||||
|
if (preg_match(
|
||||||
|
'#<img[^>]+meilisearch-uuid=["\']([a-f0-9-]{36})["\']#i',
|
||||||
|
$mainHtml,
|
||||||
|
$mm
|
||||||
|
)) {
|
||||||
|
$contentImageUuid = $mm[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================
|
* =====================
|
||||||
* PAGE (Basisdaten)
|
* PAGE (Basisdaten)
|
||||||
@@ -41,7 +60,6 @@ class MeilisearchPageMarkerListener
|
|||||||
if (!empty($page->searchimage)) {
|
if (!empty($page->searchimage)) {
|
||||||
$raw = (string) $page->searchimage;
|
$raw = (string) $page->searchimage;
|
||||||
|
|
||||||
// UUID-String oder BINARY(16)
|
|
||||||
if (preg_match('/^[a-f0-9-]{36}$/i', $raw)) {
|
if (preg_match('/^[a-f0-9-]{36}$/i', $raw)) {
|
||||||
$pageImageUuid = $raw;
|
$pageImageUuid = $raw;
|
||||||
} else {
|
} else {
|
||||||
@@ -54,7 +72,7 @@ class MeilisearchPageMarkerListener
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================
|
* =====================
|
||||||
* JSON-LD AUSWERTEN (ohne Regex-Fallen)
|
* JSON-LD AUSWERTEN
|
||||||
* =====================
|
* =====================
|
||||||
*/
|
*/
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
@@ -98,7 +116,6 @@ class MeilisearchPageMarkerListener
|
|||||||
$data['event']['searchimage'] = StringUtil::binToUuid($event->singleSRC);
|
$data['event']['searchimage'] = StringUtil::binToUuid($event->singleSRC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ STARTDATE (Unix Timestamp)
|
|
||||||
if (!empty($event->startDate)) {
|
if (!empty($event->startDate)) {
|
||||||
$data['event']['startDate'] = (int) $event->startDate;
|
$data['event']['startDate'] = (int) $event->startDate;
|
||||||
}
|
}
|
||||||
@@ -140,13 +157,20 @@ class MeilisearchPageMarkerListener
|
|||||||
*/
|
*/
|
||||||
$finalSearchImageUuid = null;
|
$finalSearchImageUuid = null;
|
||||||
|
|
||||||
if (!empty($data['event']['searchimage'])) {
|
// 🔥 TOP-PRIORITÄT: Content-Bild
|
||||||
|
if ($contentImageUuid !== null) {
|
||||||
|
$finalSearchImageUuid = $contentImageUuid;
|
||||||
|
}
|
||||||
|
elseif (!empty($data['event']['searchimage'])) {
|
||||||
$finalSearchImageUuid = $data['event']['searchimage'];
|
$finalSearchImageUuid = $data['event']['searchimage'];
|
||||||
} elseif (!empty($data['news']['searchimage'])) {
|
}
|
||||||
|
elseif (!empty($data['news']['searchimage'])) {
|
||||||
$finalSearchImageUuid = $data['news']['searchimage'];
|
$finalSearchImageUuid = $data['news']['searchimage'];
|
||||||
} elseif ($pageImageUuid) {
|
}
|
||||||
|
elseif ($pageImageUuid) {
|
||||||
$finalSearchImageUuid = $pageImageUuid;
|
$finalSearchImageUuid = $pageImageUuid;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$fallback = Config::get('meilisearch_fallback_image');
|
$fallback = Config::get('meilisearch_fallback_image');
|
||||||
if ($fallback) {
|
if ($fallback) {
|
||||||
$finalSearchImageUuid = $fallback;
|
$finalSearchImageUuid = $fallback;
|
||||||
@@ -164,38 +188,28 @@ class MeilisearchPageMarkerListener
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================
|
* =====================
|
||||||
* META-SPAN (ALLES REIN!)
|
* META-SPAN
|
||||||
* =====================
|
* =====================
|
||||||
*/
|
*/
|
||||||
$metaParts = [];
|
$metaParts = [];
|
||||||
|
|
||||||
// PAGE
|
|
||||||
if (!empty($data['page']['priority'])) {
|
if (!empty($data['page']['priority'])) {
|
||||||
$metaParts[] = 'page_priority=' . (int) $data['page']['priority'];
|
$metaParts[] = 'page_priority=' . $data['page']['priority'];
|
||||||
}
|
}
|
||||||
if (!empty($data['page']['keywords'])) {
|
if (!empty($data['page']['keywords'])) {
|
||||||
$metaParts[] = 'page_keywords=' . (string) $data['page']['keywords'];
|
$metaParts[] = 'page_keywords=' . $data['page']['keywords'];
|
||||||
}
|
}
|
||||||
if (!empty($data['page']['searchimage'])) {
|
if (!empty($data['page']['searchimage'])) {
|
||||||
$metaParts[] = 'page_searchimage=' . (string) $data['page']['searchimage'];
|
$metaParts[] = 'page_searchimage=' . $data['page']['searchimage'];
|
||||||
|
}
|
||||||
|
if ($contentImageUuid) {
|
||||||
|
$metaParts[] = 'content_searchimage=' . $contentImageUuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EVENT
|
|
||||||
if (!empty($data['event']['priority'])) {
|
|
||||||
$metaParts[] = 'event_priority=' . (int) $data['event']['priority'];
|
|
||||||
}
|
|
||||||
if (!empty($data['event']['keywords'])) {
|
|
||||||
$metaParts[] = 'event_keywords=' . (string) $data['event']['keywords'];
|
|
||||||
}
|
|
||||||
if (!empty($data['event']['searchimage'])) {
|
|
||||||
$metaParts[] = 'event_searchimage=' . (string) $data['event']['searchimage'];
|
|
||||||
}
|
|
||||||
if (!empty($data['event']['startDate'])) {
|
if (!empty($data['event']['startDate'])) {
|
||||||
$metaParts[] = 'event_startDate=' . (int) $data['event']['startDate'];
|
$metaParts[] = 'event_startDate=' . $data['event']['startDate'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$metaText = 'MEILISEARCH_META ' . implode(' | ', $metaParts);
|
|
||||||
|
|
||||||
$hiddenMeta =
|
$hiddenMeta =
|
||||||
"\n<span class=\"meilisearch-meta\" style=\"display:none !important\">" .
|
"\n<span class=\"meilisearch-meta\" style=\"display:none !important\">" .
|
||||||
"⟦MEILISEARCH_META⟧ " .
|
"⟦MEILISEARCH_META⟧ " .
|
||||||
@@ -203,11 +217,6 @@ class MeilisearchPageMarkerListener
|
|||||||
" ⟦/MEILISEARCH_META⟧" .
|
" ⟦/MEILISEARCH_META⟧" .
|
||||||
"</span>\n";
|
"</span>\n";
|
||||||
|
|
||||||
/*
|
|
||||||
* =====================
|
|
||||||
* JSON-MARKER
|
|
||||||
* =====================
|
|
||||||
*/
|
|
||||||
$marker =
|
$marker =
|
||||||
"\n<!--\nMEILISEARCH_JSON\n" .
|
"\n<!--\nMEILISEARCH_JSON\n" .
|
||||||
json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) .
|
json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) .
|
||||||
@@ -219,4 +228,4 @@ class MeilisearchPageMarkerListener
|
|||||||
? str_replace('</main>', $injection . '</main>', $buffer)
|
? str_replace('</main>', $injection . '</main>', $buffer)
|
||||||
: $buffer . $injection;
|
: $buffer . $injection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ Contao 5 – Frontend Module Template
|
|||||||
|
|
||||||
for (const hit of hits) {
|
for (const hit of hits) {
|
||||||
|
|
||||||
console.log('hit.type =', hit.type); // ← HIER
|
// console.log('hit.type =', hit.type); //
|
||||||
|
|
||||||
const node = template.content.cloneNode(true);
|
const node = template.content.cloneNode(true);
|
||||||
const item = node.children[0]; // 🔒 sicher
|
const item = node.children[0]; // 🔒 sicher
|
||||||
|
|||||||
Reference in New Issue
Block a user