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')" -->
  • What does @@Component.Key@@ show in your second scenario? – Alvin Reyes Aug 16 '13 at 10:44
7

Try this way

<!-- TemplateBeginIf cond="Component.Key != 'TrackingTag'" -->
| improve this answer | |
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 -->
| improve this answer | |
  • 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 '13 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. – Alvin Reyes Aug 16 '13 at 10:41
2

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

<!-- TemplateBeginIf cond="Component.Key='TrackingTag'" -->
 . . .
<!-- TemplateEndIf -->
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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