10

I am working on a SmartTarget module for the SDL Tridion Reference Implementation (although I guess this issue would also be applicable for DD4T).

After retrieving the promotions from SmartTarget, it appears non of the Promotions and promotions Items in the ResultSet are set to Visible. And thus XPM does not consider the Promotion on the Page part of the Region, since the IncludedInPage JSON properties in the Experience Manager Markup generated by the ResultSet.GetExperienceManagerMarkup method are all set to false:

<!-- Start Query: {
"RegionID" : "Inset 1",
"MaxItems" : 1,
"Experiments" : [
],
"Promotions" : [
    {
        "PromotionID": "6c4983b0-6f38-4540-a94a-20c8ee070fbc",
        "PromotionTitle": "SmartTarget Promotion",
        "IncludedInPage": false,
        "Items" : [
            { "ComponentID": "tcm:127-96385-16", "ComponentTemplateID": "tcm:127-96893-32", "IncludedInPage": false }
        ]
    }
]
}
-->

I suspect this may be related to the fact I am not using any of the SmartTarget TBB's in the Page Template. For as far as I can see the SmartTarget TBB's merely generate the TDCL markup in a traditional scenario, which is not applicable since the output of the Page Template is DD4T XML. But maybe some metadata is not pushed to Fredhopper by leaving them out?

Does anyone have suggestions to get this to work properly?

2 Answers 2

3

The TBBs are not required and are not a factor in this issue.

The Visible property on both items and Promotions is used to indicate if the content is displayed on the web page (and so if XPM should show it greyed out or not).

Of course, it should reflect reality as well. So if you output a Component Presentation as a result of the query, you should set the Visible property to true for both it and the Promotion that returned it.

I recommend that you call the ResultSet.filterPromotions method to do all of the standard logic that the tags/controls do. Then loop over the Promotions and their items and check the Visible property to see if you need to render the Component Presentation.

Afterwards, you can use the ResultSet.GetExperimentManagerMarkup method to output the correct JSON for XPM.

2
  • Indeed calling ResultSet.FilterPromotions before ResultSet.GetExperimentManagerMarkup did the trick :). Looking at the signature I assumed this method was only applicable for experiments, but apparently it can also be used for promotions. These methods lack detailed API documentation. Commented Feb 3, 2015 at 4:59
  • You're right, they do. Which is really a shame because they're quite important methods. My apologies for that oversight! Commented Feb 3, 2015 at 7:37
4

Indeed the SmartTarget tag library marks DPCs as IncludedOnPage. Makes sense because the SmartTarget TCDL/ASP.NET/JSP controls/tags decide how many DCPs will be shown.

Your implementation will need to set the DCPs as IncludedOnPage.

3
  • Ok. However when I manipulate the Promotions list and set the Visible properties to true, the JSON object returned by the ResultSet.GetExperienceManagerMarkup method still leaves the IncludedInPage property false. I understand from a colleague in the Java version setting this property result in the correct JSON object. Am I forgetting something? Commented Jan 30, 2015 at 18:44
  • In the Java version we use setVisible(true) on both the promotion and the item.
    – Jan H
    Commented Jan 30, 2015 at 21:02
  • Right. Doing the same in the .NET version this does not reflect accordingly in the generated JSON object :/ Commented Jan 30, 2015 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.