diff --git a/contao/dca/tl_module.php b/contao/dca/tl_module.php index 131df1b..aa36199 100644 --- a/contao/dca/tl_module.php +++ b/contao/dca/tl_module.php @@ -20,8 +20,8 @@ $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'recommendation_activate'; // Add palettes to tl_module -$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationlist'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives,recommendation_readerModule,recommendation_minRating,recommendation_featured,recommendation_order,numberOfItems,perPage;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; -$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationreader'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; +$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationlist'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives,recommendation_readerModule,recommendation_minRating,recommendation_featured,recommendation_order,numberOfItems,perPage;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize,recommendation_externalSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; +$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationreader'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize,recommendation_externalSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationform'] = '{title_legend},name,headline,type;{config_legend},recommendation_archive,recommendation_optionalFormFields,recommendation_customFieldLabel,recommendation_notify,recommendation_moderate,recommendation_disableCaptcha;{privacy_legend},recommendation_privacyText;{redirect_legend:hide},jumpTo;{email_legend:hide},recommendation_activate;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['subpalettes']['recommendation_activate'] = 'recommendation_activateJumpTo,recommendation_activateText'; @@ -178,6 +178,20 @@ 'sql' => "varchar(64) NOT NULL default ''" ]; +$GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_template'] = [ + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => static fn () => Controller::getTemplateGroup('recommendation_'), + 'eval' => ['includeBlankOption' => true, 'chosen' => true, 'tl_class'=>'w50'], + 'sql' => "varchar(64) NOT NULL default ''" +]; + +$GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_externalSize'] = [ + 'inputType' => 'text', + 'eval' => ['multiple'=>true, 'size'=>2, 'rgxp'=>'natural', 'nospace'=>true, 'tl_class'=>'w50'], + 'sql' => "varchar(64) COLLATE ascii_bin NOT NULL default ''" +]; + class tl_module_recommendation extends Backend { /** diff --git a/contao/languages/de/tl_module.xlf b/contao/languages/de/tl_module.xlf index 8fed375..796414c 100644 --- a/contao/languages/de/tl_module.xlf +++ b/contao/languages/de/tl_module.xlf @@ -125,6 +125,14 @@ Here you can select the recommendation template. Hier können Sie das Bewertungstemplate auswählen. + + External size + Externe Größe + + + Width and height of the external images in pixels (e.g. 128x128). + Breite und Höhe der externen Bilder in Pixeln (z. B. 128x128). + Sort order Sortierreihenfolge diff --git a/contao/languages/en/tl_module.xlf b/contao/languages/en/tl_module.xlf index 45df350..3232ae6 100644 --- a/contao/languages/en/tl_module.xlf +++ b/contao/languages/en/tl_module.xlf @@ -94,6 +94,12 @@ Here you can select the recommendation template. + + External size + + + Width and height of the external images in pixels (e.g. 128x128). + Sort order diff --git a/contao/modules/ModuleRecommendation.php b/contao/modules/ModuleRecommendation.php index dcae232..18e6a6d 100644 --- a/contao/modules/ModuleRecommendation.php +++ b/contao/modules/ModuleRecommendation.php @@ -29,6 +29,7 @@ * * @property string $recommendation_template * @property mixed $recommendation_metaFields + * @property mixed $recommendation_externalSize */ abstract class ModuleRecommendation extends Module { @@ -151,6 +152,17 @@ protected function parseRecommendation(RecommendationModel $objRecommendation, R $this->addInternalImage($objModel, $objTemplate); } + $size = StringUtil::deserialize($this->recommendation_externalSize); + $width = $height = 128; + + if (\is_array($size) && !empty($size[0]) && !empty($size[1])) + { + $width = $size[0]; + $height = $size[1]; + } + + $objTemplate->externalSize = ' width="' . $width . '" height="' . $height . '"'; + // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['parseRecommendation']) && \is_array($GLOBALS['TL_HOOKS']['parseRecommendation'])) { diff --git a/contao/templates/recommendation/recommendation_default.html5 b/contao/templates/recommendation/recommendation_default.html5 index 8d78357..6802e5e 100644 --- a/contao/templates/recommendation/recommendation_default.html5 +++ b/contao/templates/recommendation/recommendation_default.html5 @@ -5,7 +5,7 @@ insert('image', $this->arrData); ?> addExternalImage): ?>
- + externalSize ?> itemprop="image">
diff --git a/contao/templates/recommendation/recommendation_full.html5 b/contao/templates/recommendation/recommendation_full.html5 index c94cab4..bdb7730 100644 --- a/contao/templates/recommendation/recommendation_full.html5 +++ b/contao/templates/recommendation/recommendation_full.html5 @@ -10,7 +10,7 @@ insert('image', $this->arrData); ?> addExternalImage): ?>
- + externalSize ?> itemprop="image">
diff --git a/contao/templates/recommendation/recommendation_latest.html5 b/contao/templates/recommendation/recommendation_latest.html5 index 51b08a9..b624c5e 100644 --- a/contao/templates/recommendation/recommendation_latest.html5 +++ b/contao/templates/recommendation/recommendation_latest.html5 @@ -5,7 +5,7 @@ insert('image', $this->arrData); ?> addExternalImage): ?>
- + externalSize ?> itemprop="image">