1

It's my first time implementing Sitecore ECM feature. I've cut up some html templates into layouts and sublayouts, created the datasources I needed, and made a branch template with the $name item set to be of template "AB Testable message".

Following Frank Rooijen's blog post: http://www.newguid.net/sitecore/2013/building-custom-newsletter-templates-for-sitecores-ecm-2-x/ I've set the body field in the $name to go to my message root child, set all the sublayout datasources to the relevant child items of the message root.

Andit all works fine!

What I really want to know is how the sublayout's datasource paths are derived to their new location after being instantiated from the create/insert action from the ECM Speak page.

I've been using reflector to try and get some insight, but I don't think I'm looking in the right places.

Marek Musielak
  • 26,832
  • 8
  • 72
  • 80
munsense
  • 49
  • 4

2 Answers2

2

The ECM package adds a new config file at /App_Config/Includes/Sitecore.EmailCampaign.config. Within that file you can see some new event handlers are added, most notably:

<event name="item:added">
    <handler type="Sitecore.Modules.EmailCampaign.Core.ItemEventHandler, Sitecore.EmailCampaign" method="OnItemAdded" />
</event>
<event name="item:copied">
    <handler type="Sitecore.Modules.EmailCampaign.Core.ItemEventHandler, Sitecore.EmailCampaign" method="OnMessageCopied" />
</event>

If you decompile Sitecore.EmailCampaign.dll and look at the corresponding Class and follow through the code you will see call to MessageRelationsCorrector.CorrectItemRelations() which handles all the work to replace the IDs of the DataSources of new created and copied messages.

jammykam
  • 16,940
  • 2
  • 36
  • 71
0

jammykam is spot on.

The one thing that I'd add though (after banging my head for a while) is that even though the processing first does a check on template descends from AB Testable Message or the other email types, the actual correction of item relations only happens if the email template is exactly one of the built-in templates like AB Testable Message. Don't try and have you own template that derives. Sigh.

benmccallum
  • 1,241
  • 12
  • 27