Closed soulseekah closed 5 months ago
Thanks for reporting this!
After digging into this, I noticed the same thing: that the core mailer will set the template mode to use the CP templates, even though we do override the template mode in the internal plugin parser.
I have a fix for this that will be included in the next version. It will make sure all include paths will be relative to your site templates folder.
<templates folder>/mjml/_mjml-welcome.twig
, do this: <mj-include path="./mjml/_mjml-welcome.twig" />
<templates folder>
, do this: <mj-include path="./_mjml-welcome.twig" />
I don't think your full description is correct, however: it is not necessary to copy all your MJML templates to every site subfolder - Craft will look into both your main templates folder AND your site subfolder, and pick the most specific one. This I conclude both from reading the core code and from testing on a multisite setup.
Let me know if the fix doesn't fully resolve your issue.
Craft core Mailer assumes all email templates are
View::TEMPLATE_MODE_CP
which grabs templates from/app/templates/
without the additional insiteHandle
for the current or default site. This is configurable. But theMJMLService::include
method looks inView::TEMPLATE_MODE_SITE
instead, which grabs templates from/app/templates/$siteHandle/mjml
. This means that we have to copy and maintain MJML templates for all sites. There is hardly a good way to override this behavior.This can be reproduced when triggering an email from the CP. Also via unit tests.
Error:
[mjml] 'Could not generate output: Could not render template: mjml/subsite/_mjml-welcome.twig'