Developer forum

Forum » Templates » Template Context for EmailMarketing

Template Context for EmailMarketing

Ronni Hansen
Ronni Hansen
Reply

I have been stuggling for a few days with the email marketing module, and think it is time i request some external assistance :-)

When i am sending an email via the EmailMarketing module, it seems that the context in @PageView.Context is null. (I have checked the "render content" checkbox in the email, if i dont, the PageView it self will be null).

The problem is, that i need the Context to request a Tag set on the Recipient in our custom recipient provider, with a redirect url.

 

I am unsure if this is related, but i have also had problems with the handlebar syntax, and when it is parsed, in relation to the dw-"link-wrapper".

<a href="http://someurl.com/{{handlebardata}}">HelloWorld</a> results in dw creating a link.aspx, with an underlying incorrect url: http://someurl.com/%7B%7Bhandlebardata%7D%7D instead of using the content of the variable.

Same thing happens if you use razor: <a href="http://someurl.com/@razorvariable">Hello World</a> result: http://someurl.com/%40razorvariable

If i fully build the url in razor, it does however work. I cannot do it without the context though :-)

 

Hope it makes sense, and that you can help me :)

Best Regards

Ronni

 

 

 

 


Replies

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi Ronni,

You should override method GetRecipientContentContext in your custom provider, e.g.:

        /// <summary>
        /// Gets the recipient content context. This method is used when rendering recipient specific content.
        /// </summary>
        /// <param name="recipient">The recipient.</param>
        /// <returns>The <see cref="PageViewContext" /> to render the associated page with.</returns>
        public override PageViewContext GetRecipientContentContext(Recipient recipient)
        {
            PageViewContext pvc = new PageViewContext();
            pvc.SetValue("RecipientKey", recipient.RecipientKey);
            return pvc;
        }

Best regards,

Vladimir

 
Aki Ruuskanen
Aki Ruuskanen
Reply

Nice. This is what I was looking for. yes

 

You must be logged in to post in the forum