Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I escape ${} in my Tridion Component Template that is consumed by multiple templates?

I am running into a situation where I have a fied with the value ${test}, in my component template that renders this the value comes out ok the problem comes in when another template calls this component and templates using @@RenderComponentPresentation(Component.ID, MyFirstTemplate)@@ at this point the ${test} is evaluated and because there is no such item on the component or in the package it evaluates to nothing.

  • I have Component Template One that reads the value of a Component field (which contains: ${test})

    • This template renders fine, I get back "${test}"
  • Now I have Component Template Two that calls @@RenderComponentPresentation(Component.ID, ComponentTemplateOne.ID)@@

    • This is where the ${test} now gets evaluated instead of retained so it goes from ${test} to "" because it doesn't find a variable or component field name with that name.
  • Component Template Two then gets called by Component Template Three in the same way @@RenderComponentPresentation(Component2.ID, ComponentTemplateTwo.ID)@@

    • Since the ${test} has already been evaluated and lost in Component Template Two I no longer end up with ${test} I am still left with "".

I have tried:

  • @@RenderComponentField('myField', 0, False, False)@@
  • @@RenderComponentField('myField', 0, True, False)@@
  • @@RenderComponentField('myField', 0, False, True)@@

no luck.

The following was my work around and it seems to work:

  • Placing the "\" in front of both the open and close curly brace $\{test\}
  • I need to make sure I remove the "\" after the last Template (Page or Component) executes.
  • I have in place now a C# TBB that takes the "${test}" and does the following to it:
    • Converts the ${test} to $\{test\} in the initial template and a C# TBB on the Page Template that then returns it to the initial value of ${test}.

Is there a way to prevent this from happening or a way to avoid doing what i am doing to make this work?

like image 277
TridionNut Avatar asked Sep 13 '12 15:09

TridionNut


1 Answers

Have you tried this link , you should be able to this with this link

@@"$" + "{" + "test" + "}"@@
like image 132
vikas kumar Avatar answered Nov 19 '22 11:11

vikas kumar