How do Macro Expressions in Email Templates Work?

Al Burns asked on March 20, 2020 16:16

Hi. I was wondering if someone could explain how macro expressions in email templates work. As an example, the "Membership - Registration confirmation" email template consists of:

{% GetResourceString("email.template.html.header")|(encode)false #%}
    <p>Thank you for registering at our site. Please click the link below to complete your registration:</p>
    <p><a href="{%confirmaddress%}">{%confirmaddress%}</a></p>
{% GetResourceString("email.template.html.footer")|(encode)false #%}

Where "confirmaddress" is classed as a context specific object when you click the add macro link in the template but where is this defined and how is it resolved. Also, can you create your own custom macro expressions that you can add here? If so, where do you define them?


Correct Answer

Dmitry Bastron answered on March 20, 2020 17:03

Hi Al,

In email templates apart from standard macros you obviously can use custom. The only thing you need to do is to register a macro data source with your data before sending the email. You can read more about it in this blog post or if you need to show non-Kentico .NET object look at this question.

But as far as I know, in order to register your custom datasources for email templates you need to write actually email sending code (like in the article above). So you need to hook to membership registration event, register your datasources for email, and send email with this template.

0 votesVote for this answer Unmark Correct answer

Recent Answers

Al Burns answered on March 20, 2020 17:57

Thanks Dimitry, I'll take a look at those posts.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.