diff --git a/src/EventListener/IndexPageListener.php b/src/EventListener/IndexPageListener.php index 4b83c2d..afafb03 100644 --- a/src/EventListener/IndexPageListener.php +++ b/src/EventListener/IndexPageListener.php @@ -6,19 +6,6 @@ class IndexPageListener { public function onIndexPage(string $content, array &$data, array &$set): void { - echo PHP_EOL; - echo '================ MEILI INDEX DEBUG ================' . PHP_EOL; - echo '--- CONTENT (first 500 chars) ---------------------' . PHP_EOL; - echo substr(strip_tags($content), 0, 500) . PHP_EOL; - - echo '--- DATA (tl_search record, BEFORE write) ---------' . PHP_EOL; - print_r($data); - - echo '--- SET (context) ---------------------------------' . PHP_EOL; - print_r($set); - - echo '==================================================' . PHP_EOL; - echo PHP_EOL; } } \ No newline at end of file diff --git a/src/EventListener/MeilisearchPageMarkerListener.php b/src/EventListener/MeilisearchPageMarkerListener.php new file mode 100644 index 0000000..d89099e --- /dev/null +++ b/src/EventListener/MeilisearchPageMarkerListener.php @@ -0,0 +1,38 @@ +priority; + $keywords = trim((string) $page->keywords); + + // nichts gesetzt → nichts schreiben + if ($priority <= 0 && $keywords === '') { + return; + } + + $lines = []; + $lines[] = 'MEILISEARCH'; + + if ($priority > 0) { + $lines[] = 'page.priority=' . $priority; + } + + if ($keywords !== '') { + $lines[] = 'page.keywords=' . $keywords; + } + + $comment = + "\n\n"; + + // HTML am Ende anhängen + $pageData['output'] .= $comment; + } +} \ No newline at end of file diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 45734df..8db67b5 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -1,5 +1,14 @@ $this->getPageSearchData((int) ($set['pageId'] ?? 0)), - 'news' => $this->getNewsSearchData((int) ($set['newsId'] ?? 0)), - 'calendar' => $this->getEventSearchData((int) ($set['eventId'] ?? 0)), - default => null, - }; - } - - private function getPageSearchData(int $pageId): ?array - { - if ($pageId <= 0) { - return null; - } - - $row = Database::getInstance() - ->prepare('SELECT priority, keywords FROM tl_page WHERE id=?') - ->execute($pageId) - ->fetchAssoc(); - - return $row ? [ - 'priority' => (int) $row['priority'], - 'keywords' => (string) $row['keywords'], - ] : null; - } - - private function getNewsSearchData(int $newsId): ?array - { - if ($newsId <= 0) { - return null; - } - - $row = Database::getInstance() - ->prepare('SELECT priority, keywords FROM tl_news WHERE id=?') - ->execute($newsId) - ->fetchAssoc(); - - return $row ? [ - 'priority' => (int) $row['priority'], - 'keywords' => (string) $row['keywords'], - ] : null; - } - - private function getEventSearchData(int $eventId): ?array - { - if ($eventId <= 0) { - return null; - } - - $row = Database::getInstance() - ->prepare('SELECT priority, keywords FROM tl_calendar_events WHERE id=?') - ->execute($eventId) - ->fetchAssoc(); - - return $row ? [ - 'priority' => (int) $row['priority'], - 'keywords' => (string) $row['keywords'], - ] : null; - } -} \ No newline at end of file