广告系列监控器中带有模板变量的IF / ELSEIF

时间:2018-06-25 12:27:44

标签: php campaign-monitor

我正在从RSS feed发送电子邮件活动,我需要检查每个帖子的优先级以显示在模板中。

我在每封邮件上仅发送一封帖子。

PHP后端代码为:

$this->apiCampaigns()->create_from_template($config['client_id'], [
    'Name' => '['.date('d/m/Y H:i').'] '.$feed->title,
    'Subject' => $feed->title,
    'FromName' => $config['mail.from.name'],
    'FromEmail' => $config['mail.from.address'],
    'ReplyTo' => $config['mail.from.address'],
    'SegmentIDs' => [$this->segment()],
    'TemplateID' => $this->template(),
    'TemplateContent' => [
        'priority' => $feed->priority,

        'Singlelines' => [
            [
                'Content' => $feed->title
            ],
            [
                'Content' => $feed->description
            ],
            [
                'Content' => 'AMPLIAR INFORMACIÓN',
                'Href' => $feed->link
            ]
        ]
    ]
]);

将模板中的编码代码为:

[if:priority="baja"]

<h3>Importancia baja</h3>
<img class="u-mx-auto" alt="Indicador alerta baja" width="220" src="images/indicador_alerta_baja.png">

[elseif:priority="media"]

<h3>Importancia media</h3>
<img class="u-mx-auto" alt="Indicador alerta media" width="220" src="images/indicador_alerta_media.png">

[elseif:priority="alta"]

<h3>Importancia alta</h3>
<img class="u-mx-auto" alt="Indicador alerta alta" width="220" src="images/indicador_alerta_alta.png">

[endif]

但是除priority之外,所有代码都可以正常工作。永远不要显示任何值。

如何将priority值传递给模板?

谢谢!

0 个答案:

没有答案