Add Index Listener
This commit is contained in:
@@ -8,12 +8,10 @@ class MeilisearchEventMarkerListener
|
|||||||
{
|
{
|
||||||
public function onParseFrontendTemplate(string $buffer, string $template): string
|
public function onParseFrontendTemplate(string $buffer, string $template): string
|
||||||
{
|
{
|
||||||
// Nur Event-Reader
|
|
||||||
if ($template !== 'mod_eventreader') {
|
if ($template !== 'mod_eventreader') {
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contao 5: objEvent!
|
|
||||||
if (
|
if (
|
||||||
!isset($GLOBALS['objEvent']) ||
|
!isset($GLOBALS['objEvent']) ||
|
||||||
!$GLOBALS['objEvent'] instanceof CalendarEventsModel
|
!$GLOBALS['objEvent'] instanceof CalendarEventsModel
|
||||||
@@ -21,7 +19,12 @@ class MeilisearchEventMarkerListener
|
|||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = $GLOBALS['objEvent'];
|
// 🔥 Event vollständig aus DB laden
|
||||||
|
$event = CalendarEventsModel::findByPk($GLOBALS['objEvent']->id);
|
||||||
|
|
||||||
|
if ($event === null) {
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
$GLOBALS['MEILISEARCH_MARKERS']['event'] = [
|
$GLOBALS['MEILISEARCH_MARKERS']['event'] = [
|
||||||
'priority' => (int) ($event->priority ?? 0),
|
'priority' => (int) ($event->priority ?? 0),
|
||||||
|
|||||||
@@ -2,33 +2,33 @@
|
|||||||
|
|
||||||
namespace MummertMedia\ContaoMeilisearchBundle\EventListener;
|
namespace MummertMedia\ContaoMeilisearchBundle\EventListener;
|
||||||
|
|
||||||
use Contao\CalendarEventsModel;
|
use Contao\NewsModel;
|
||||||
|
|
||||||
class MeilisearchEventMarkerListener
|
class MeilisearchNewsMarkerListener
|
||||||
{
|
{
|
||||||
public function onParseFrontendTemplate(string $buffer, string $template): string
|
public function onParseFrontendTemplate(string $buffer, string $template): string
|
||||||
{
|
{
|
||||||
if ($template !== 'mod_eventreader') {
|
if ($template !== 'mod_newsreader') {
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!isset($GLOBALS['objEvent']) ||
|
!isset($GLOBALS['objNews']) ||
|
||||||
!$GLOBALS['objEvent'] instanceof CalendarEventsModel
|
!$GLOBALS['objNews'] instanceof NewsModel
|
||||||
) {
|
) {
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🔥 Event vollständig aus DB laden
|
// News vollständig nachladen (Custom-Felder!)
|
||||||
$event = CalendarEventsModel::findByPk($GLOBALS['objEvent']->id);
|
$news = NewsModel::findByPk($GLOBALS['objNews']->id);
|
||||||
|
|
||||||
if ($event === null) {
|
if ($news === null) {
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
$GLOBALS['MEILISEARCH_MARKERS']['event'] = [
|
$GLOBALS['MEILISEARCH_MARKERS']['news'] = [
|
||||||
'priority' => (int) ($event->priority ?? 0),
|
'priority' => (int) ($news->priority ?? 0),
|
||||||
'keywords' => trim((string) ($event->keywords ?? '')),
|
'keywords' => trim((string) ($news->keywords ?? '')),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $buffer;
|
return $buffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user