Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Email template theme locations in 3.1


Go to End


4 Posts   952 Views

Avatar
Mo

Community Member, 541 Posts

17 September 2014 at 11:31pm

Edited: 18/09/2014 9:28am

Hi All,

I have been having issues with placing email templates in Silverstripe 3.1

If I use the following:

$email = new Email($from, $to, $subject, $body);
$email->setTemplate('MyEmail');
$email->populateTemplate(Member::currentUser());
$email->send();

Then add the template "MyEmail.ss" into the "/silverstripe-root/themes/mytheme/templates/email" directory, then Silverstripe cannot find it.

If I add "MyEmail.ss" to the "/silverstripe-root/mysite/templates/email" directory, then the template is found.

Anyone else getting this? I have had the same issue on several projects, I set the current theme in config.yml, so not sure what the issue is...

Cheers,

Mo

Avatar
UncleCheese

Forum Moderator, 4102 Posts

2 October 2014 at 4:29pm

Hey, mo --

I was just dealing with this yesterday, actually. I assume you're trying to send an email in the CMS? There's no theme in the CMS, so any templates that will be accessed from within the admin need to be in a module, e.g. mysite/.

Avatar
Mo

Community Member, 541 Posts

3 October 2014 at 9:45pm

Hi Unclecheese,

I have been getting this on the back of a CMS form. I was also getting it when trying to send an email on the back of an onAfterWrite, but (thinking about it) the object was written through the CMS as well.

I guess I would have to manually give Email the path of the template file if I want to use it in a theme. But will Email support that?

I will do some digging,

Cheers for the help,

Mo

Avatar
UncleCheese

Forum Moderator, 4102 Posts

6 October 2014 at 10:05am

What is the path to the template you're trying to use? The only restriction is that it cannot be in themes/.