我已经构建了一个非常简单的模块来学习如何集成使用自定义树枝模板发送电子邮件的快速邮件模块。
位于以下位置的默认迅捷邮件小枝模板的副本:http://cgit.drupalcode.org/swiftmailer/tree/templates/swiftmailer.html.twig被稍加修改,并按照文件本身中包含的说明重命名:
* 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".
*
这个小枝文件的名称是swiftmailer--emailtester.html.twig,它位于active themes/mytheme/templates文件夹中。
当我执行调用以在emailtester.module内发送电子邮件并遍历核心中的ThemeManager.php、twig.engine.php和Render.php文件中的调用时,模板路径指向the/modules/contrib/swiftmailer/templates/swiftmailer.html.twig文件而不是/themes/mytheme/templates/swiftmailer--emailtester.html.twig文件。
我已经使用drush cr清除了缓存,并清除了config->performance部分中的所有缓存。我也尝试过清除主题注册表,但似乎没有什么改变,因为迅捷邮件总是回到使用它的全局模板文件。
如有任何建议,将不胜感激。
干杯,
德文
发布于 2017-07-28 09:58:55
您可能选择了要用于电子邮件模板的错误主题:
如果您选择“当前”并在管理页上发送邮件,则将只使用来自管理主题的更快的邮件模板。因此,确保您选择的主题,其中包含您的自定义迅捷邮件小枝文件。如果这是您的标准前端主题,您可以选择“默认”。
当然,您必须将Swiftmailer设置为格式化程序。
发布于 2019-04-16 14:42:41
在您在content-type
钩子中指定module_mail
头之前,将不会使用该模板。比如:
$headers = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal',
);
https://stackoverflow.com/questions/41991792
复制相似问题