我正在从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
值传递给模板?
谢谢!