主题化Drupal 8+;快捷邮件联系人电子邮件
我正在尝试使用swiftmailer在Drupal 8站点中为我的联系人电子邮件设置主题,但有一些困难。我正在尝试使用swiftmailer的默认主题文件,但它会呈现所有正文。如何单独访问每个字段 我想做的是这样的:主题化Drupal 8+;快捷邮件联系人电子邮件,drupal,themes,swiftmailer,drupal-8,Drupal,Themes,Swiftmailer,Drupal 8,我正在尝试使用swiftmailer在Drupal 8站点中为我的联系人电子邮件设置主题,但有一些困难。我正在尝试使用swiftmailer的默认主题文件,但它会呈现所有正文。如何单独访问每个字段 我想做的是这样的: {# /** * @file * The default template file for e-mails. * * Available variables: * - subject: The subject. * - body: The message conten
{#
/**
* @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>
{#
/**
*@file
*电子邮件的默认模板文件。
*
*可用变量:
*-主题:主题。
*-body:消息内容。
*-message:在邮件构建中创建并使用的$message数组
*程序。其内容因情况而异,但通常包含
*至少应包括以下要素:
*-id:消息标识符。
*-module:处理消息生成的模块。
*-键:消息的键。
*-收件人:收件人的电子邮件地址。
*-发件人:发件人的电子邮件地址。
*-langcode:用于撰写电子邮件的语言代码。
*-params:消息参数。
*
*此模板可由模块和/或邮件密钥覆盖,使用
*以下模板名称:
*-swiftmailer.html.twig:global,默认使用。
*-swiftmailer--mymodule.html.twig:仅由模块“mymodule”发送的电子邮件。
*-swiftmailer--mymodule--test.html.twig:仅模块发送的电子邮件
*带“测试”键的“mymodule”。
*
*@请参阅模板预处理()
*@请参阅模板\u预处理\u swiftmailer()
*
*@ingroup主题表
*/
#}
表tr td{
字体系列:Arial;
字体大小:12px;
}
td.场{
宽度:50px;
}
诺姆
{{body.name}
电子邮件
{{body.mail}
莫蒂沃
{{body.motivo}}
提特罗
{{body.subject}}
男装
{{body.message}}
这看起来很简单,但花的时间太多了。所有“body.something”都是空白的
谢谢电子邮件的参数通常(当然取决于实现)在
message.params中。我建议您使用message.params
访问所需的变量
此外,为了提供帮助,您可以使用devel模块并使用{{dump()}
打印出该主题文件中可用的所有变量,并从中发现您的内容所在。电子邮件的参数通常(当然取决于实现)在message.params中。我建议您使用message.params
访问所需的变量
此外,为了提供帮助,您可以使用devel模块并使用{{dump()}
打印出该主题文件中可用的所有变量,并从中发现您的内容所在。这些变量都列在模板顶部
* 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.
您将在模板中使用以下内容:-
{{ subject }}
{{ body }}
{{ message.to }}
{{ message.params.YOUR_PARAM }}
等等。所有变量都列在模板顶部
* 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.
您将在模板中使用以下内容:-
{{ subject }}
{{ body }}
{{ message.to }}
{{ message.params.YOUR_PARAM }}
等等。message.params.field_name对我不起作用。字段都在正文中一次显示,我不知道如何单独访问字段。您是否有定义参数的邮件发送功能?message.PARAMs.field_name不适用于我。字段都在正文中一次性显示,我不知道如何单独访问字段。您是否有定义参数的邮件发送功能?转储(正文)正在工作,但并不真正感兴趣。dump(message.params)不显示任何内容。dump(body)正在工作,但并不真正感兴趣。转储(message.params)不显示任何内容。