Jump to content

Customizing notification template to include topic title


Vova Zk

Recommended Posts

Posted

Hi, I’m trying to make email subject lines include topic titles when a new mention is made, but they just fail to work (no email is sent at all).

The way I did it is was by inserting this line in "Languages" instead of the default one for mailsub__core_notification_mention:

Quote

Re: {$comment->item()->mapped("title")|raw}

Moreover, when I try to replace the default one for mailsub__core_notification_new_comment (which is precisely “{$comment->item()->mapped("title")|raw}”) to “Re: {$comment->item()->mapped("title")|raw}” (with just the addition of "Re: "), it stops working, too (no emails sent).

What am I doing wrong?

Posted

First and foremost, do NOT use the |raw modifier here. A content item title (such as a topic title) is user-generated/submitted content, and a malicious user could submit a topic title that contains XSS in it. You do not want to embed raw javascript or other potentially malicious content directly into an email using |raw.

Secondly, I cannot see any reason or duplicate any problems adding "Re:" to the new_comment email template.

For the mention template, the mention could be for a topic or for a comment, so you need to do it like so:

Re: {{if $content instanceof \IPS\Content\Comment}}{$content->item()->mapped('title')}{{else}}{$content->mapped('title')}{{endif}}

 

Posted

@bfarberThank you so much, Brandon! I’ll try that out and let you know if it worked!

As for the "raw" snippet, I believe I took it from an existing mailing template. Maybe I misunderstood something, though!

Upd. It worked like magic, thanks once again! And no, I didn't take it from an email template (I wonder where did I take it from, then... — but that's a question for another day :) ).

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...