In my initial DD4T + SmartTarget 2014 integration solution (http://www.tridiondeveloper.com/dd4t-and-sdl-smarttarget-2014-integration) I was trying to achieve something similar to the DefaultComponentPresentationRenderer.RenderComponentPresentations()
, but for SmartTarget, where you pass in the Region name. However, I ran into an issue where once we get the DCPs out of SmartTarget, we need to send them through to the appropriate View or Controller/Action as per the Component Template metadata (see RenderComponentPresentation
method here: https://code.google.com/p/dynamic-delivery-4-tridion/source/browse/branches/web-assembly/dotnet/DD4T.Mvc/Html/DefaultComponentPresentationRenderer.cs).
The problem is that in the context of DCPs, DD4T actually doesn't seem to publish a ComponentPresentation model, it publishes only the Component. The IComponentPresentation is actually only available when using the ComponentPresentationRenderer
in context of a Page. (See raw XMLs coming out of DD4T: when rendering the Page, we get <Page>
with <ComponentPresentation>
elements, and those have <Template>
and <Component>
elements. However, when publishing a DCP standalone the XML only has the <Component>
element and not info about the CT.)
This works fine for 99% of the cases since in the stand-alone DCP (pageless) scenarios, our application logic dictates which Controller, Action and View to use: the editor doesn't need control in this case. However, with the "helper" approach to SmartTarget, we actually need the CP object, the component doesn't suffice.
My question is: from a purest and cleanest architecture perspective, should DD4T TBBs be modified to publish the Component Presentation (in the Dynamic case) instead of just the Component, or is there another way to retrieve the Component Template metadata (or title) from a DD4T DCP?