Skip to content

Commit

Permalink
Add a redirect option do enable/disable the logo module (see #31)
Browse files Browse the repository at this point in the history
* Make logo link optional 479a1c3

* Update README ecc02d5

* Change link to redirect c83af6c

---------

Co-authored-by: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com>
  • Loading branch information
de-es and zoglo authored Oct 9, 2024
1 parent 3b6ea64 commit 35dc68f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down
10 changes: 9 additions & 1 deletion contao/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
];
2 changes: 1 addition & 1 deletion contao/languages/de/modules.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</trans-unit>
<trans-unit id="FMD.socialmedialist.0">
<source>Social media list</source>
<target>Social-Media Liste</target>
<target>Social-Media-Liste</target>
</trans-unit>
<trans-unit id="FMD.socialmedialist.1">
<source>Generates a list based on the stored social media links</source>
Expand Down
8 changes: 8 additions & 0 deletions contao/languages/de/tl_module.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<source>Logo settings</source>
<target>Logo-Einstellungen</target>
</trans-unit>
<trans-unit id="tl_module.companyLogoRedirect.0">
<source>Activate redirect</source>
<target>Weiterleitung aktivieren</target>
</trans-unit>
<trans-unit id="tl_module.companyLogoRedirect.1">
<source>Adds a redirect to the website root.</source>
<target>Fügt eine Weiterleitung zum Startpunkt der Website hinzu.</target>
</trans-unit>
</body>
</file>
</xliff>
6 changes: 6 additions & 0 deletions contao/languages/en/tl_module.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<trans-unit id="tl_module.logo_legend">
<source>Logo settings</source>
</trans-unit>
<trans-unit id="tl_module.companyLogoRedirect.0">
<source>Activate redirect</source>
</trans-unit>
<trans-unit id="tl_module.companyLogoRedirect.1">
<source>Adds a redirect to the website root.</source>
</trans-unit>
</body>
</file>
</xliff>
1 change: 1 addition & 0 deletions contao/modules/ModuleLogo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion contao/templates/modules/mod_logo.html5
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

<?php $this->block('content'); ?>

<?php if ($this->addRedirect): ?>
<a href="<?= $this->rootHref ?>" title="<?= $this->title ?>">
<?php $this->insert('image', $this->arrData); ?>
<?php endif; ?>
<?php $this->insert('image', $this->arrData); ?>
<?php if ($this->addRedirect): ?>
</a>
<?php endif; ?>

<?php $this->endblock(); ?>

0 comments on commit 35dc68f

Please sign in to comment.