Skip to content

Commit

Permalink
Add a custom text field to the subscribe module (see contao/core-bund…
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Jun 28, 2018
1 parent cfff528 commit 26cfb4d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

## DEV

* Add a custom text field to the subscribe module (see contao/core-bundle#1512).
* Use type="email" in the default template (see #20).
12 changes: 11 additions & 1 deletion src/Resources/contao/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// Add palettes to tl_module
$GLOBALS['TL_DCA']['tl_module']['palettes']['personalData'] = str_replace(',editable', ',editable,newsletters', $GLOBALS['TL_DCA']['tl_module']['palettes']['personalData']);
$GLOBALS['TL_DCA']['tl_module']['palettes']['subscribe'] = '{title_legend},name,headline,type;{config_legend},nl_channels,nl_hideChannels,disableCaptcha;{redirect_legend},jumpTo;{email_legend:hide},nl_subscribe;{template_legend:hide},nl_template;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['subscribe'] = '{title_legend},name,headline,type;{config_legend},nl_channels,nl_hideChannels,disableCaptcha;{text_legend},nl_text;{redirect_legend},jumpTo;{email_legend:hide},nl_subscribe;{template_legend:hide},nl_template;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['unsubscribe'] = '{title_legend},name,headline,type;{config_legend},nl_channels,nl_hideChannels,disableCaptcha;{redirect_legend},jumpTo;{email_legend:hide},nl_unsubscribe;{template_legend:hide},nl_template;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['newsletterlist'] = '{title_legend},name,headline,type;{config_legend},nl_channels;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['newsletterreader'] = '{title_legend},name,headline,type;{config_legend},nl_channels;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
Expand All @@ -36,6 +36,16 @@
'sql' => "blob NULL"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['nl_text'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['nl_text'],
'exclude' => true,
'inputType' => 'textarea',
'eval' => array('rte'=>'tinyMCE', 'helpwizard'=>true),
'explanation' => 'insertTags',
'sql' => "text NULL"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['nl_hideChannels'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['nl_hideChannels'],
Expand Down
13 changes: 12 additions & 1 deletion src/Resources/contao/languages/en/tl_module.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<trans-unit id="tl_module.nl_channels.1">
<source>Please select one or more channels.</source>
</trans-unit>
<trans-unit id="tl_module.nl_text.0">
<source>Custom text</source>
</trans-unit>
<trans-unit id="tl_module.nl_text.1">
<source>Here you can e.g. enter a privacy note to make the newsletter subscription GDPR compliant.</source>
</trans-unit>
<trans-unit id="tl_module.nl_hideChannels.0">
<source>Hide channel menu</source>
</trans-unit>
Expand All @@ -38,6 +44,9 @@
<trans-unit id="tl_module.nl_template.1">
<source>Here you can select the newsletter template.</source>
</trans-unit>
<trans-unit id="tl_module.text_legend">
<source>Custom text</source>
</trans-unit>
<trans-unit id="tl_module.text_subscribe.0">
<source>Your subscription on %s</source>
</trans-unit>
Expand All @@ -46,7 +55,9 @@

##channels##

Please click ##link## to activate your subscription. If you did not subscribe yourself, please ignore this e-mail.
Please click ##link## to activate your subscription.

You can unsubscribe from our newsletter at any time. If you did not subscribe yourself, please ignore this e-mail.
</source>
</trans-unit>
<trans-unit id="tl_module.text_unsubscribe.0">
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/contao/modules/ModuleSubscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @property string $nl_subscribe
* @property array $nl_channels
* @property string $nl_template
* @property string $nl_text
* @property bool $nl_hideChannels
*
* @author Leo Feyer <https://github.com/leofeyer>
Expand Down Expand Up @@ -158,6 +159,7 @@ protected function compile()
$this->Template->action = \Environment::get('indexFreeRequest');
$this->Template->formId = $strFormId;
$this->Template->id = $this->id;
$this->Template->text = $this->nl_text;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/contao/templates/newsletter/nl_default.html5
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@

<?= $this->captcha ?>

<?php if ($this->text): ?>
<div class="widget widget-explanation">
<?= $this->text ?>
</div>
<?php endif; ?>

<div class="widget widget-submit">
<button type="submit" class="submit"><?= $this->submit ?></button>
</div>
Expand Down

0 comments on commit 26cfb4d

Please sign in to comment.