Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

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!

share|improve this question

3 Answers 3

up vote 3 down vote accepted

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.

share|improve this answer
    
    
@RobStevenson-Leggett you mother, What more can i say? the post explains how to exactly what this chap is looking for! :) –  johnwinter Aug 31 at 2:22

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

share|improve this answer
1  
This is the way I'd imagined it working –  Rob Stevenson-Leggett Aug 25 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. –  Chris Morgan Aug 26 at 14:18

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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