【发布时间】:2017-02-01 23:30:00
【问题描述】:
我构建了一个非常简单的模块来学习如何集成 swiftmailer 模块来发送使用自定义 twig 模板的电子邮件。
默认 swiftmailer 树枝模板的副本位于此处: 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".
*
twig 文件的名称是 swiftmailer--emailtester.html.twig,它位于活动的主题/mytheme/templates 文件夹中。
当我执行调用以在 emailtester.module 中发送电子邮件并遍历 Core 中的 ThemeManager.php、twig.engine.php 和 Render.php 文件中进行的调用时,模板路径指向 /modules/contrib/swiftmailer/templates/swiftmailer.html.twig 文件,而不是 /themes/mytheme/templates/swiftmailer--emailtester.html .twig 文件。
我已经使用 drush cr 清除了我的缓存,并清除了 config->performance 部分中的所有缓存。我也尝试过清除主题注册表,但似乎没有任何区别,因为 swiftmailer 总是回退到使用其全局模板文件。
任何建议将不胜感激。
干杯,
德文
【问题讨论】:
-
此时遇到完全相同的问题!这曾经解决过吗?如果我找到一个解决方案,我会发布一个!
-
启用 twig 调试 cmets 并检查生成的电子邮件 html。您的模板名称是否列在 FILE NAME SUGGESTIONS 下?
标签: twig swiftmailer drupal-8