Add Index Listener
This commit is contained in:
@@ -4,6 +4,7 @@ namespace MummertMedia\ContaoMeilisearchBundle\EventListener;
|
|||||||
|
|
||||||
use Contao\PageModel;
|
use Contao\PageModel;
|
||||||
use Contao\StringUtil;
|
use Contao\StringUtil;
|
||||||
|
use Contao\Config;
|
||||||
|
|
||||||
class MeilisearchPageMarkerListener
|
class MeilisearchPageMarkerListener
|
||||||
{
|
{
|
||||||
@@ -18,17 +19,28 @@ class MeilisearchPageMarkerListener
|
|||||||
$priority = (int) ($page->priority ?? 0);
|
$priority = (int) ($page->priority ?? 0);
|
||||||
$keywords = trim((string) ($page->keywords ?? ''));
|
$keywords = trim((string) ($page->keywords ?? ''));
|
||||||
|
|
||||||
// 🔹 searchimage (UUID)
|
// 🔹 searchimage (Page → Fallback)
|
||||||
$searchImageUuid = null;
|
$searchImageUuid = null;
|
||||||
|
|
||||||
|
// 1. Page-spezifisch
|
||||||
if (!empty($page->searchimage)) {
|
if (!empty($page->searchimage)) {
|
||||||
// falls binär → UUID-String
|
|
||||||
$searchImageUuid = StringUtil::binToUuid($page->searchimage);
|
$searchImageUuid = StringUtil::binToUuid($page->searchimage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. Fallback aus tl_settings
|
||||||
|
if (!$searchImageUuid) {
|
||||||
|
$fallback = Config::get('meilisearch_fallback_image');
|
||||||
|
if ($fallback) {
|
||||||
|
$searchImageUuid = StringUtil::binToUuid($fallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wenn wirklich GAR nichts vorhanden ist → nichts tun
|
||||||
if ($priority <= 0 && $keywords === '' && !$searchImageUuid) {
|
if ($priority <= 0 && $keywords === '' && !$searchImageUuid) {
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔹 Marker aufbauen
|
||||||
$lines = [];
|
$lines = [];
|
||||||
$lines[] = 'MEILISEARCH';
|
$lines[] = 'MEILISEARCH';
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,16 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_imagesize'] = [
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_settings']['fields']['meilisearch_fallback_image'] = [
|
||||||
|
'inputType' => 'fileTree',
|
||||||
|
'eval' => [
|
||||||
|
'filesOnly' => true,
|
||||||
|
'fieldType' => 'radio',
|
||||||
|
'tl_class' => 'w50',
|
||||||
|
],
|
||||||
|
'sql' => "varbinary(16) NULL",
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Palette
|
* Palette
|
||||||
*/
|
*/
|
||||||
@@ -61,4 +71,5 @@ PaletteManipulator::create()
|
|||||||
->addField('meilisearch_index', 'meilisearch_legend')
|
->addField('meilisearch_index', 'meilisearch_legend')
|
||||||
->addField('meilisearch_api', 'meilisearch_legend')
|
->addField('meilisearch_api', 'meilisearch_legend')
|
||||||
->addField('meilisearch_imagesize', 'meilisearch_legend')
|
->addField('meilisearch_imagesize', 'meilisearch_legend')
|
||||||
|
->addField('meilisearch_fallback_image', 'meilisearch_legend')
|
||||||
->applyToPalette('default', 'tl_settings');
|
->applyToPalette('default', 'tl_settings');
|
||||||
@@ -13,3 +13,8 @@ $GLOBALS['TL_LANG']['tl_settings']['meilisearch_api'][1] = 'API-Schlüssel für
|
|||||||
|
|
||||||
$GLOBALS['TL_LANG']['tl_settings']['meilisearch_imagesize'][0] = 'Bildgröße für Vorschaubilder';
|
$GLOBALS['TL_LANG']['tl_settings']['meilisearch_imagesize'][0] = 'Bildgröße für Vorschaubilder';
|
||||||
$GLOBALS['TL_LANG']['tl_settings']['meilisearch_imagesize'][1] = 'Bildgröße aus den Contao-Bildgrößen (tl_image_size).';
|
$GLOBALS['TL_LANG']['tl_settings']['meilisearch_imagesize'][1] = 'Bildgröße aus den Contao-Bildgrößen (tl_image_size).';
|
||||||
|
|
||||||
|
$GLOBALS['TL_LANG']['tl_settings']['meilisearch_fallback_image'] = [
|
||||||
|
'Fallback-Bild für die Suche',
|
||||||
|
'Dieses Bild wird verwendet, wenn für eine Seite, News oder ein Event kein Suchbild gesetzt ist.',
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user