0

I'm currently working on a Tridion website and a cookie law must be set up. Right now, in the content Components, there is a possibility to add HTML code through a text field.

If this HTML code contains a tag like this one:

<iframe src="http://www.slideshare.net/slideshow/embed_code/58264?rel=0">&nbsp;</iframe>

I need to include it within some C# code in order to show/hide it , depending on what the user has chosen in term of cookies. For example, if the user decides to disable slideshare, the src attribute changes and display something else.

In my DWT, this is the block of code that takes care of displaying what is written in the text field:

<!-- TemplateBeginIf cond="Field.content" -->
@@RenderComponentField("Fields.Paragraph[${paragraphindex}].content",0)@@
<!-- TemplateEndIf -->

I don't know how to achieve this. Hope I'm clear enough and you understand my question. Thank you in advance.

1
  • It sounds like you're looking to do an else statement. It's not clear what exactly you need to do with C#. With DWT unfortunately you can't do an 'else, but you can do a not if Commented May 17, 2016 at 15:14

1 Answer 1

1

Keep in mind the basics, the template expression language in your DWT Template Building Block is executed at publish time, when the Template is rendered.

But I think what you are asking for is a way to show or hide something at request time of your (ASPX) page. This is not comething you can (or should) solve in your DWT TBB directly, but in the outcome of it. So that means you need to generate C# code which will be executed at request time. Keep in mind you are generating this code at publish time, to be executed at request time, so there is no way to debug it either from the Template Builder, for what Tridion is concerned, that code is simply plain text.

So you need to figure out what you need in your (ASPX) page, like you would have on a website not being published by Tridion. Then make sure you write out that code in the Template. Apart from doing it using server side code, you can also achieve this using JavaScript, JS can also access your cookie, and it might make a whole lot more sense generating some JS to be outputted by your DWT TBB, than generating C#.

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.