我已經構建了一個非常簡單的模塊,以瞭解如何整合swiftmailer模塊來發送使用自定義樹枝模板的電子郵件。使用Swiftmailer的自定義Drupal 8模塊忽略樹枝模板
設在這裏的默認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".
*
樹枝文件的名稱是swiftmailer - emailtester .html.twig它位於活動主題/ mytheme/templates文件夾中。
當我執行調用emailtester.module內發送電子郵件,並通過電話走正在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總是回退到使用其全局模板文件。
任何建議將不勝感激。
歡呼聲,
德文
目前遇到完全相同的問題!這是否解決?我會發佈一個解決方案,如果我找到一個! –
啓用樹枝調試註釋並檢查生成的電子郵件html。您的模板名稱是否在FILE NAME SUGGESTIONS下列出? –