【发布时间】:2016-08-29 02:33:03
【问题描述】:
我正在尝试使用 swiftmailer 在 Drupal 8 站点中为我的联系电子邮件设置主题,但遇到了一些困难。我正在尝试使用 swiftmailer 的默认主题文件,但它会呈现所有正文。如何单独访问每个字段?
我想做的是这样的:
{#
/**
* @file
* The default template file for e-mails.
*
* Available variables:
* - subject: The subject.
* - body: The message content.
* - message: The $message array created and used in the mail building
* procedure. Its content varies between cases, but typically contains at
* least the following elements:
* - id: The message identifier.
* - module: The module that handles the building of the message.
* - key: The key of the message.
* - to: The recipient email address.
* - from: The email address of the sender.
* - langcode: The langcode to use to compose the e-mail.
* - params: The message parameters.
*
* This template may be overriden by module and/or mail key, using any of the
* following template names:
* - swiftmailer.html.twig: global, used by default.
* - swiftmailer--mymodule.html.twig: only emails sent by the module "mymodule".
* - swiftmailer--mymodule--test.html.twig: only emails by the module
* "mymodule" with key "test".
*
* @see template_preprocess()
* @see template_preprocess_swiftmailer()
*
* @ingroup themeable
*/
#}
<html>
<head>
<style type="text/css">
table tr td {
font-family: Arial;
font-size: 12px;
}
td .field {
width: 50px;
}
</style>
</head>
<body>
<div>
<table width="800px" cellpadding="0" cellspacing="0">
<tr>
<td class="field">Nome</td>
<td>{{ body.name }}</td>
</tr>
<tr>
<td class="field">Email</td>
<td>{{ body.mail }}</td>
</tr>
<tr>
<td class="field">Motivo</td>
<td>{{ body.motivo }}</td>
</tr>
<tr>
<td class="field">Titulo</td>
<td>{{ body.subject }}</td>
</tr>
<tr>
<td class="field">Mensagem</td>
<td>{{ body.message }}</td>
</tr>
</table>
</div>
</body>
</html>
这似乎很简单,但它花费了太多时间。所有“body.something”都是空白的。
谢谢
【问题讨论】:
标签: drupal themes swiftmailer drupal-8