11

Possible Duplicate:
Variable setting in Dreamweaver template in SDL Tridion

We use RenderComponentPresentation (on Tridion 2009) to render internal and external links so that the code base is in only one Dreamweaver template. It would be helpful if we could pass through an optional CSS Class to use when rendering the link.

Any ideas how this could be done?

Community
  • 1
  • 1
frontendzzzguy
  • 3,242
  • 21
  • 31
  • Hi Puf, I've tried that and it doesn't help my situation. Thanks anyway. – frontendzzzguy May 03 '12 at 12:52
  • Is this for SDL Tridion 2011 or 2009? Perhaps you can update your question to reflect that. Perhaps you can also explain where your DWTs are located? Are you trying to pass a value from a Page Layout DWT to a Component Layout DWT? – Chris Summers May 03 '12 at 12:55

1 Answers1

16

It is possible to set a value in the RenderContext and then retrieve it in the second Dreamweaver template.

Before calling RenderComponentPresentation set a render context value as follows:

@@SetRenderContextVariable("CSSClass","red")@@  

You will need to have a C# Fragment or TBB to get the variables out of the render context and add them to the package in the second Dreamweaver template. An example would be:

var renderContext = engine.PublishingContext.RenderContext;
foreach (string key in renderContext.ContextVariables.Keys)
{
    var value = renderContext.ContextVariables[key] as string;
    var item = package.CreateStringItem(ContentType.Text, value);
    package.PushItem("RenderContextVariable."+key, item);
}

You should then be able to access the variables within the package using the standard Dreamweaver notation

@@RenderContextVariable.CSSClass@@

Hope this helps!

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks Chris, I'll try this out now and see if it works. – frontendzzzguy May 03 '12 at 12:53
  • 2
    If you have access to the SDL Tridion docs, this is detailed here http://sdllivecontent.sdl.com/LiveContent/content/en-US/SDL_Tridion_2011_SPONE/idheading-359879368 and it is in the Tridion Cookbook at http://code.google.com/p/tridion-practice/wiki/BuiltInFunctionsForUseInHtmlTemplates – Chris Summers May 03 '12 at 13:03