markocupic/newsletter-notify-on-subscription-activation-bundle

在新闻通讯订阅激活时发送通知。

1.0.4 2020-09-20 07:59 UTC

This package is auto-updated.

Last update: 2024-09-20 16:26:51 UTC


README

Contao >=4.4 的前端模块

当访客在您的网站上注册新闻通讯时,通过 terminal42/notification_center 发送通知。通知将在访客通过电子邮件链接确认其新闻通讯注册后发送。

安装

composer require markocupic/newsletter-notify-on-subscription-activation-bundle

设置通知(通知中心)

在“通知”后端模块中创建一个“新闻通讯通知 -> 新闻通讯注册激活”类型的通知。

可用token包括##recipient_##和##newsletter_##。

使用##recipient_email##可以在NC中输出新订阅者的电子邮件地址。其他字段可以通过##recipient_*##输出。

使用##newsletter_title##可以在NC中输出新闻通讯频道的标题。其他字段可以通过##newsletter_*##输出。

现在,您只需在新闻通讯模块中激活此通知即可。

可选:通过钩子调整token

示例类用于钩子的使用方法请见此处 此处:这样可以进一步根据需要调整token。

<?php

/**
 * Send notifications on newsletter subscription activation
 * extension for Contao Open Source CMS
 *
 * @copyright  Copyright (c) 2019, markocupic
 * @author     markocupic <m.cupic@gmx.ch>
 * @link https://github.com/markocupic/newsletter-notify-on-subscription-activation-bundle
 * @license    MIT
 */

namespace Markocupic;

/**
 * Class BeforeNotifyOnSubscriptionActivation
 * @package Markocupic
 */
class BeforeNotifyOnSubscriptionActivation
{

    /**
     * Pass $arrTokens by reference!!!
     * @param $arrTokens
     * @param $objSubscriber
     * @param $objChannel
     * @param $objNotification
     * @return bool
     */
    public function beforeNotifyOnSubscriptionActivation(&$arrTokens, $objSubscriber, $objChannel, $objNotification)
    {
        $arrTokens['recipient_email'] = 'hans_muster@foofoo.bar';
        $arrTokens['newsletter_title'] = 'My incredible newsletter';

        // Return true, if notification should be sent
        return true;
    }

}

像往常一样,在模块的config.php中注册钩子。

// config.php
$GLOBALS['TL_HOOKS']['beforeNotifyOnSubscriptionActivation'][] = array('Markocupic\BeforeNotifyOnSubscriptionActivation','beforeNotifyOnSubscriptionActivation');