用于定制摘要和通知邮件的钩子

I have a client who would like to include ads in summary and notification emails. I’ve “crafted” a plugin that allows adding some text to the digest email (which I think needs some updating to catch up with changes made to that template).

I don’t like that I have to override the entire template to customize those emails.

Would it be possible to include a way to add to those emails without overriding the template?

The plugin works by having taking a topic ID in a custom field and including raw of the last post in the topic as the text added to the email (just before or after the header). Though I think it’s a pretty clever hack, that seems a bit too fiddly a solution to suggest adding to core. Perhaps there’s a way to have the Ad plugin be able to apply house ads to the digest and summary emails?

Managing a fragile plugin

Maybe I should write a spec that compares the digest email with the plugin off with the digest email with the plugin on but not configured to add anything to the email? Then I’d catch changes to the core template?

6 个赞

嘿 Jay

这个插件支持 Discourse 3.1 吗?或者值得测试吗?

你可以试试。我想我自从收到这条消息后就没再收到过他们的消息了,所以我想他们从那时起就没有升级过。

如果它坏了,你可以告诉我。我可能没时间免费修复它,但我也许会。

2 个赞

据我所知,digest_custom_htmldigest_custom_text 已经为 digest.html.erbdigest.text.erb 实现了钩子。那么,实现此请求的基本方法是否涉及添加更多此类钩子?

更高级的实现可以提供子模板,用于向插件作者提供由 Discourse 维护的样式和格式代码。

我是否正确理解,您的实现可以通过在 digest.html.erb 中添加一个 digest_custom_html("before_preheader") 来实现?

我也这么认为。我多年来没有仔细看过它是如何工作的。

@thoka,你通过那些钩子实现了什么吗?我们目前正在通过那些钩子注入一些简单的赞助内容。

我已经完成了。只要你使用 html_safe 生成注入内容,你就没问题了。

相关讨论请参见 Fixing digest_custom_html to be treated as HTML (was: Overriding digest.html.erb)

2 个赞