Bug reports Found a bug? Post it here please.
Version 7.x > Bug reports > Nested Macros not resolving in Newsletter templates View modes: 
User avatar
Member
Member
lancetek - 12/11/2013 8:13:34 AM
   
Nested Macros not resolving in Newsletter templates
Hi,
We just upgraded from v5.5R2 to v7.0.61. I have a custom macro that is used an email newsletter. It uses the old way to pass parameters into a custom macro:

It looks like: {#GetAndCreateUserAbcResubscriptionLink|{%Email%}|{%domain%}#}

When the code for GetAndCreateUserAbcResubscriptionLink is hit in Visual Studio, the parameter contains {%Email%}|{%domain%}, so it looks like the nested macro resolver isn't working in regards to newsletters.

Of course in my custom GetAndCreateUserAbcResubscriptionLink the CMS.Context.CurrentUser contains my administrative user details instead of the info about the email subscriber.


So my question is: I'd like to know how to get my nested macro working in v7?

Thanks,
Lance

User avatar
Member
Member
lancetek - 12/12/2013 1:49:03 PM
   
RE:Nested Macros not resolving in Newsletter templates
FIXED:

So the BIG problem is that the macro was not returning any Context about the email subscriber... the {%Email%} value was not being parsed, the literal value of '{%Email%} was getting passed into the Custom Macro function.

I ended up doing minor modifications to the macro by calling it like:
{%GetAndCreateUserAbcResubscriptionLink%}

And in that function pulling in the subscriber's email from the Resolver of the Macro Context object like this:
if (null != e.Resolver.SourceTables)
subscriberEmail = e.Resolver.SourceTables[0]["email"].ToString();

Note that this works for both Email Subscribers and Email Users who are Subscribers.

User avatar
Member
Member
lancetek - 12/12/2013 1:51:49 PM
   
RE:Nested Macros not resolving in Newsletter templates
Whoops! I noticed a typo, here's how you actually call it:
{%Custom.GetAndCreateUserAbcResubscriptionLink%}

Using the Custom prefix and the % Context macro braces somehow magically populates the context object with the information I was seeking!