-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Email->setHTMLTemplate/setPlainTemplate in combination with SSViewer::get_templates_by_class #11062
Comments
In your snippet I only see the |
The second .ss comes from
|
Semi off-topic, but it might be helpful as an alternative - we’ve all but stopped using $html = ArrayData::create(['Asset' => $asset, 'Message' => $message])
->renderWith(['App\Email\AssetMessageEmail', 'App\Email\Email']);
$email = Email::create()->setBody($html); It allows us to have a template structure similar to page templates, which can then use templates/App/Email/Email.ss <html>
<head>
... some meta tags, global styles etc might live here
</head>
<body>
... shared email header
{$Layout}
... shared email footer
</body>
</html> templates/App/Email/Layout/AssetMessageEmail.ss <p><strong>Message:</strong> {$Message}</p> I wonder if it would be possible to add a |
That sounds like a good idea. I'd recommend we also deprecate the current |
Version 5.x
Description
The method
Email->setHTMLTemplate
currently only accepts a single relative template name.Because it must be a string, you cannot pass the response from
SSViewer::get_templates_by_class
to it.And because of this if: https://github.com/silverstripe/silverstripe-framework/blob/5/src/Control/Email/Email.php#L416 you cannot even pass the response of
SSViewer::chooseTemplate
. Because the .ss extension is stripped from the file and will lead to the error"/absolute/path/to/file_without_extension" does not exists
A workaround I found is to add the .ss extension twice ...
The text was updated successfully, but these errors were encountered: