Email templates in Telligent Enterprise 4.0 look and function very similarly to widgets in the Widget Studio. If you are upgrading from 2.x to 4.0, the changes you need to make in migrating any template changes from 2.x to 4.0 email templates aren’t as simple as copy and paste, but are still quite simple. We’ll use the 2.6 weblog_newcomment.txt template as an example. In 4.0, this template is called blog_comment.xml.
Let's look at the weblog_newcomment.txt template:
From: $helpers.FormatFrom($post.Section.Name,$settings.NotificationFromEmailAddress) To: Bcc: $subscribers
Subject: $mime.EncodeHeader($post.Section.Name, $charSet): New comment for $mime.EncodeHeader($parent.Subject, $charSet)
#if(!$IsHtml)
#mimebody("text/plain" $charSet)
From: $post.User.DisplayName Posted: $mg.RenderText($post.BlogPostTypeName) To: $parent.Subject in $post.Section.Name Link: $post.Uri $mg.RenderText($post) -- You were sent this email because you opted to receive email notifications when someone created a new comment to the post $parent.Subject at $post.Section.Name. To unsubscribe, visit $globals.FullPath($blogurls.UnsubscribeThread($post.Weblog, $user.PublicToken, $user.Username, $post.PostID))
#end
#else
#mimebody("text/html" $charSet)
<div style='font-family: arial; font-size: 10pt;'> <div style='font-size: 12pt;'><b><a href='$post.Uri'>$parent.Subject</a>: New Comment</b></div> By $post.User.DisplayName<br/><br/> <div>$mg.RenderHtml($post)</div> <div style='color: #7F7F7F; font-size: 8pt;'> <p> <a href='$post.Uri'>View this post online</a>. </p> </div>
</div>
#end
#end
- In yellow (lines 1-3) are the email headers defining From, To, and BCC.
- In orange (line 4) is the subject.
- In green (lines 8-16) is the plaintext version of the email.
- In blue (lines 20-29) is the HTML version of the email.
Now, let's look at the new blog_coment.xml template:
<emailTemplates>
<emailTemplate name="blog_comment">
<subject>
<![CDATA[
$core_v2_blog.Current.Name: New comment for $core_v2_blogPost.Current.Title
]]>
</subject>
<htmlBody>
<![CDATA[
#set($post = $core_v2_blogPost.Current) #set($comment = $core_v2_blogComment.Current) <div style='font-family: arial; font-size: 10pt;'> <div style='font-size: 12pt;'> <b><a href='$core_v2_blogUrls.BlogPost($post.Id)'>$post.Title</a>: New Comment</b> </div> By $comment.Author.DisplayName<br/> <p> $email_utility.RenderHtml($comment) </p> <div style='color: #7F7F7F; font-size: 8pt;'> <p> <a href='$core_v2_blogUrls.BlogPost($post.Id)'>View this post online</a>. </p> </div> </div>
]]>
</htmlBody>
<textBody>
<![CDATA[
#set($post = $core_v2_blogPost.Current) #set($comment = $core_v2_blogComment.Current) From: $comment.Author.DisplayName To: $post.Title in $core_v2_blog.Current.Name Link: $core_v2_blogUrls.BlogPost($post.Id) $email_utility.RenderText($comment)
]]>
</textBody>
</emailTemplate>
</emailTemplates>
Note that there is no yellow area. Headers don't need to be declared any more. The basic ones are handled by Telligent Enterprise automatically. We can still manipulate them, though, which we'll see shortly.
- In orange (line 5) is the subject
- In blue (lines 10-26) is the HTML version of the email
- In green (lines 31-38) is the plaintext version of the email
You’ll notice the contents in corresponding colors in each template look very similar (that is, the way content is retrieved has changed, but the overall formatting is maintained). If any changes were made in the 2.x template, note them, find the matching area in the 4.0 template, and apply your changes to that template.
Also notice that To, From, and Bcc are no longer defined in the template. These values are automatically populated for each email.
Manipulating headers is now done using the $email_header extension. The usage is $email_header.SetHeader(header, value). For example, $email_header.SetHeader(“X-Example”, “This is just an example”) will set the “X-Example” header and give it the value “This is just an example”. Additional email header extension information can be found at http://<your-site-url>/controlpanel/ApiDocumentation/Extension.aspx?name=email_header&api=email.
This same process can be used for upgrading all email templates.
Related information