Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Dynamic Newsletter custom macro View modes: 
User avatar
Member
Member
beau.cowan-rrpartners - 10/8/2013 7:02:53 PM
   
Dynamic Newsletter custom macro
I'm not too familiar with macros just yet, and I'm trying to follow this article: Resolving macros in Dynamic Newsletter, so that I can create a dynamic newsletter and still be able to have the unsubscribe link work properly.

I've created the static and dynamic newsletters, having the dynamic one going to a page in my CMS so that I can add webparts or other things to it. I also have the custom macro class in my App_Code folder, but when it gets to the part that talks about,
Secondly, we need to create static newsletter and some issue containing our custom macro which ideally should hold code name of our dynamic newsletter ( {#dynamic#} )
, I'm not sure if I need to put something into the class to call up the newsletter I have in my CMS or what.

Can I get a little more explaination into this please? I've gone through the documention 3 times and still have a hard time understanding what needs to be in the custom class.

User avatar
Member
Member
kentico_sandroj - 10/20/2013 1:45:24 PM
   
RE:Dynamic Newsletter custom macro
Hello,

This request was posted in the v7 section and in v7 the solution is to use the following macro directly on the page:
{%UnsubscribeLink|(resolver)subscriber%}

If you meant to post this in v6 please let me know and I will explain the code. Basically, in the macro you are getting the newsletter by the codename specified when you create the dynamic newsletter:
InfoDataSet<Newsletter> newsletter = NewsletterProvider.GetNewsletters("NewsletterName = '" + e.Expression + "'", "", 1, "NewsletterID");

Once you have the object the following code gets the ID:
ValidationHelper.GetInteger(DataHelper.GetDataRowValue(newsletter.Tables[0].Rows[0], "NewsletterID"), 0);

Then an issue is generated from the ID:
EmailQueueManager.GenerateDynamicIssue(newsletterId);

Then the replacement macro is replaced with the correct values in order to resolve at the correct point in the process, when the information is available:
e.Result = issue.IssueText.Replace("{§", "{ %").Replace("§}", " %}");

Please let me know if you have any questions.

Best Regards,
Sandro