10

Implementing SmartTarget on a development VM, and I've discovered that there's a surprising lack of information about how to use SmartTarget inside of DD4T. I understand that the Razor engine is almost a completely separate entity from the standard ASP.NET WebForms, so the use of custom controls (e.g., <smarttarget:query runat="server"...) isn't supported.

I'm thinking that using REL in my views might work, as that's a runtime Java operation separate from the standard tag handling that occurs server-side.

Is there an established best practice for using SmartTarget within DD4T, and if not what have you used to render promotions in regions? And why?

This is partly an academic exercise, partly practice. The lack of information on the topic suggests that there is no wrong answer (unless you tell me it can't be done; at which I say, "Phooey!").

I was thinking that plain REL would work:

<tcdl:query id='query2' timeout='2000' publication='tcm:0-31-1' allowDuplicates='true'>
    <tcdl:promotions region='Sidebar' maxItems='10' var='promos'>
        <h4>Showing #{promos.size} promotions</h4>
        <tcdl:itemTemplate var='promo' items='#{promos}'>
            <tcdl:promotionalItems var='promoItems'>
                <tcdl:itemTemplate var='promoItem' items='#{promoItems}'>
                    <tcdl:ComponentPresentation ComponentURI='#{promoItem.componentUri}' TemplateURI='#{promoItem.templateUri}' Type='Dynamic'/>
                </tcdl:itemTemplate>
            </tcdl:promotionalItems>
        </tcdl:itemTemplate>
    </tcdl:promotions>
</tcdl:query>

Thank you in advance for your suggestions and answers!

3 Answers 3

3

This post : http://www.tridiondeveloper.com/dd4t-and-sdl-smarttarget-2014-integration

Contains an explanation of what you're looking to do as well as code helper to get you up and running.

2
10

Another way of doing this would be to write a number of mvc html helpers that would use the smarttarget query api to fetch promotions etcetera.

The flow would be something like

  • get parameters from the html helper (promo name, nr of items, region name,...)

  • construct a smarttarget query

  • send a query and receive xml with results. I believe the results are tcm uris of published components and the component template they are published with

  • retrieve these from the broker

  • render each component, and return the htmlstring to the view

Advantage of this is that you could use custom actions to render the components just like you would render any other dd4t component

2
  • 1
    This is the way I'd imagined it working Commented Aug 25, 2014 at 22:00
  • 2
    Hot from the ST Bootcamp. Use ST to get TCMID, but render it from the Tridion CD API to ensure component linking etc works as expected. Commented Aug 26, 2014 at 14:18
6

You could put the content out using REL and transform the TCDL tags yourself. when you return your content from the broker.

EDIT

I agree with the process Harald discusses above - I have tested and confirm you can get the Component Presentation HTML - BUT any dynamic component links are not available (it doesn't go through the Tridion REL engine) - it seems this Component Presentation is really only for the Preview functionality within FH.

You should get the Comp and Comp Template ID's and render the CPs directly from the Broker database.

There's a useful article on REL by Will here.

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.