9

This is fairly simple:

<!-- TemplateBeginIf cond="Component.Key=='TrackingTag'" -->
 . . .
<!-- TemplateEndIf -->

However, I'm stuck with reverse condition. For example in C# we usually do:

if(!String.IsNullOrEmpty()) // 

So I want the Equivalent in DWT :

This was tried but Not working. condition !(Component.Key=='TrackingTag') always comes true.

<!-- TemplateBeginIf cond="!(Component.Key=='TrackingTag')" -->
1
  • What does @@Component.Key@@ show in your second scenario? Aug 16, 2013 at 10:44

3 Answers 3

7

Try this way

<!-- TemplateBeginIf cond="Component.Key != 'TrackingTag'" -->
9

Siva answered how you check for inequality, but I'll chime in how to check for existence.

The equivalent of String.IsNullOrEmpty(Component.Key) would probably be

<!-- TemplateBeginIf cond="Component.Key" -->

This condition will only pass if Component.Key exists and it has a value.

People often use that construct to ensure that a field exists/has a value, before they write the wrapper tags:

<!-- TemplateBeginIf cond="Component.Subtitle" -->
  <h3>${Component.Subtitle}</h3>
<!-- TemplateEndIf -->
2
  • ok. But i need the reverse. if something doesn't exists, i need to include the lines inside. So: <!-- TemplateBeginIf cond="!Component.Subtitle" --> will work ?
    – R.C
    Aug 16, 2013 at 8:02
  • 1
    !Component.Key works to show markup for me when the field is empty. But if your schema allows multiple Key values, you may want a loop in addition to checking individual fields. Aug 16, 2013 at 10:41
2

Do not need to use "==" for string operand, try like below,

<!-- TemplateBeginIf cond="Component.Key='TrackingTag'" -->
 . . .
<!-- TemplateEndIf -->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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