Hi, i would like to change the css style of the recap template (digest), that is sent to users.
Unfortunately the only part of the digest that is editable is the logo, which can be done via site settings.
CSS in email is quite a tricky task, so we’ve hardcoded the styles in the template:
https://github.com/discourse/discourse/blob/master/app/views/user_notifications/digest.html.erb
Hi @eviltrout, thank you very much for the answer, i really appreciate it.
Is there a way to overwrite this file? Maybe with a plugin?
Unfortunately I don’t think .erb
templates can be overridden in plugins, although maybe someone on the @team could correct me.
The .erb template can’t be overridden by a plugin.
Car Talk has its own digest emails. How we did that in a plugin was to treat it as a new email entirely. You could disable Discourse’s default digest emails and then use your own. It’s more complicated than making a new template though…
- Create a new scheduled job in the plugin that is the same as enqueue_digest_emails.rb but will queue your new email.
Jobs.enqueue(:my_custom_digest_email, user_id: user_id)
- Create your new mailer in
app/mailers
. Copy the digest method from the user_notifications.rb mailer into your mailer. - Put your new template for the email in
app/views/mailers/my_custom_digest_email
.
Not ideal, but gives you a lot of freedom to customize the data and logic.
One small thing that could be useful here: a way to change the header image size for this email. See below images — in the first (default) the header image is almost comically tiny (40px height). The latter I tried making three times larger (120px, the actual size of the uploaded image) and it looks much better. Not sure if there’s any way to do this currently but would be nice to be able to use the larger image!
Where can I find this file in my server? I need to change it manually. As reported here, digest emails have serious problems with rtl language and I cant wait till it gets fixed.
Is there anyway to style the element span.badge-category-bg used in the New for you section of these emails? I’ve noticed there’s some inheritence of styling from the customisable stylesheets into the digest, and we have a problem where these items are not sized properly in email clients.
Me too. 40px just isn’t large enough to have the logo blend in with the rest of the template, which uses HUGE fonts.
It can.
I have created a plugin for client to override the default digest template.
Feel free to publish it in the plugin category
I have published it:
I wonder if there’s a better way to do that now, which does not require a custom plugin nor direct code editing?
November 2017 calling. Is it possible to customize all parts of the email now? Use our own html template?
Sadly, I don’t think the state of the art in emails have progressed much…
@neil can you clarify why it isn’t possible to override an erb template with a plugin?
thanks!
@davedogs Is this not what you want:
I tried something similar for ActionViews but it did not work (need it to change the template for user notification emails)
::ActionView::Base.prepend_view_path File.expand_path("…/custom_views", FILE)
Tried this as well (from here)
::ActionViews::ViewPaths.prepend_view_path File.expand_path("…/custom_views", FILE)
Any ideas? New to Ruby/Rails so pardon my mistakes.
Edit: Not working means discourse won’t start.
Found the solution in this topic
I try to customize the summary digest email. According to this topic, it seems possible:
The email setting apply custom styles to digest
is enabled but I can not find the summary email in the customizable email templates.
Where can I find the customizable template for summary emails ?