I’m trying to adapt mail subject to a blog post content by changing mail template (xwiki/bin/edit/XWiki/Notifications/MailTemplate?editor=object&classname=XWiki.Mail&object=0&force=1).
Is it possible to add velocity content into “subject” ? I’d like to change mail subject according to the content of a blog post. Something like that :
#if ($blog_post_content.contains("incident"))
# set ($subject = "New incident")
#else
# set ($subject = "$services.localization.render('notifications.email.subject', [$events.size()])")
#end
Is it possible to do such a thing ? Do I have to modify macro.vm file ? Otherwise, what about adding to different XWiki.mail objects ?
Thanks for the quick reply.
I’ve already modifyed this template, but I’ve only been able to modify the mail body but not the mail subject.
It seems that it’s not possible to add velocity code into subject part because editor permits only one line into it.
I don’t think that adding an other object to manage languages is the answer for my question.
What could I do to make mail subject variable according to mail content ?
The subject xproperty is also rendered using velocity. By default, it is: $services.localization.render('notifications.email.subject', [$events.size()])
Sorry, I don’t think we’re understanding each other. I know the default value :
$services.localization.render(‘notifications.email.subject’, [$events.size()])
in mail template.
But, I’d like it to be variable according to the message content, something like that :
#if ($blog_post_content.contains("incident"))
# set ($subject = "New incident")
#else
# set ($subject = "$services.localization.render('notifications.email.subject', [$events.size()])")
#end
But the editor doesn’t allow to enter several lines. Where should I had this code ?
I tried to execute any velocity simple code into the “subject” field, but it did’nt work : no mail was sent.
I won’t investigate more as we decided to change the way to notify users (through teams chanels).
Thanks a lot for the answers anyway