From 35dc68ff34be57c7003609a252f31f0cc86da66d Mon Sep 17 00:00:00 2001 From: de-es Date: Wed, 9 Oct 2024 06:49:09 +0000 Subject: [PATCH] Add a redirect option do enable/disable the logo module (see #31) * Make logo link optional 479a1c3ec9fe1634f40e9f695b179a5185188d81 * Update README ecc02d578d839bb47305caaf8ee3555d42d92079 * Change link to redirect c83af6c22330751191260047ad0895e76bad602f --------- Co-authored-by: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> --- README.md | 5 +++-- contao/dca/tl_module.php | 10 +++++++++- contao/languages/de/modules.xlf | 2 +- contao/languages/de/tl_module.xlf | 8 ++++++++ contao/languages/en/tl_module.xlf | 6 ++++++ contao/modules/ModuleLogo.php | 1 + contao/templates/modules/mod_logo.html5 | 6 +++++- 7 files changed, 33 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cdb987a..b5b397a 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,8 @@ Keep in mind that saving these will overwrite the modules and insert-tags for th 1. Create the front-end module *Logo* 2. Set up an image size -3. Embed the module within your layout (e.g. header-section) or in your articles +3. Decide wether the logo should redirect to the website root +4. Embed the module within your layout (e.g. header-section) or in your articles ### Social media list @@ -246,7 +247,7 @@ Your company information can be displayed using following *insert-tags*. ## Front end modules ### Logo (Company) -Displays the saved company logo. +Displays the saved company logo with an optional redirect to the website root. The image for the logo-module is set up within the system or root page settings. diff --git a/contao/dca/tl_module.php b/contao/dca/tl_module.php index 43e9f2c..0697940 100644 --- a/contao/dca/tl_module.php +++ b/contao/dca/tl_module.php @@ -11,5 +11,13 @@ */ // Add palettes to tl_module -$GLOBALS['TL_DCA']['tl_module']['palettes']['logo'] = '{title_legend},name,headline,type;{logo_legend},imgSize;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; +$GLOBALS['TL_DCA']['tl_module']['palettes']['logo'] = '{title_legend},name,headline,type;{logo_legend},imgSize,companyLogoRedirect;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['palettes']['socialmedialist'] = '{title_legend},name,headline,type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; + +// Add fields to tl_module +$GLOBALS['TL_DCA']['tl_module']['fields']['companyLogoRedirect'] = [ + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => ['tl_class'=>'w50 m12'], + 'sql' => "char(1) NOT NULL default '1'" +]; diff --git a/contao/languages/de/modules.xlf b/contao/languages/de/modules.xlf index 8dc2e3a..4a76aef 100644 --- a/contao/languages/de/modules.xlf +++ b/contao/languages/de/modules.xlf @@ -15,7 +15,7 @@ Social media list - Social-Media Liste + Social-Media-Liste Generates a list based on the stored social media links diff --git a/contao/languages/de/tl_module.xlf b/contao/languages/de/tl_module.xlf index 0ffaf81..445d08d 100644 --- a/contao/languages/de/tl_module.xlf +++ b/contao/languages/de/tl_module.xlf @@ -5,6 +5,14 @@ Logo settings Logo-Einstellungen + + Activate redirect + Weiterleitung aktivieren + + + Adds a redirect to the website root. + Fügt eine Weiterleitung zum Startpunkt der Website hinzu. + diff --git a/contao/languages/en/tl_module.xlf b/contao/languages/en/tl_module.xlf index 3e2281c..53df43c 100644 --- a/contao/languages/en/tl_module.xlf +++ b/contao/languages/en/tl_module.xlf @@ -4,6 +4,12 @@ Logo settings + + Activate redirect + + + Adds a redirect to the website root. + diff --git a/contao/modules/ModuleLogo.php b/contao/modules/ModuleLogo.php index 0f9a323..60da7b8 100644 --- a/contao/modules/ModuleLogo.php +++ b/contao/modules/ModuleLogo.php @@ -121,6 +121,7 @@ protected function compile(): void $this->Template->rootHref = $strPageUrl; $this->Template->title = $strCompanyName; + $this->Template->addRedirect = $this->companyLogoRedirect; } protected function isFrontendPreview(): bool diff --git a/contao/templates/modules/mod_logo.html5 b/contao/templates/modules/mod_logo.html5 index cd5f78c..33edaac 100644 --- a/contao/templates/modules/mod_logo.html5 +++ b/contao/templates/modules/mod_logo.html5 @@ -2,8 +2,12 @@ block('content'); ?> + addRedirect): ?> - insert('image', $this->arrData); ?> + + insert('image', $this->arrData); ?> + addRedirect): ?> + endblock(); ?>