Developer forum

Forum » Templates » If condition is ignored

If condition is ignored

Jim Trebbien
Reply

There is a productfield on the products in ecommerce. The product is a textfield (Long text). What I need to do is check if the field contains any text.
If it does it should be displayed, if not, it should display something else.

This is the template code:

<!--@If Defined(Ecom:Product:Field.ingrediensliste)-->
 <!--@Ecom:Product:Field.ingrediensliste.Value-->
<!--@Else-->
<!--@LoopStart(BOMProducts)-->
            <!--@Ecom:Product.Name-->,
  <!--@LoopEnd(BOMProducts)-->
<!--@End If-->

The problem is that no matter if there is text in the field, both cases of the if gets written.
 


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Have you tried If Defined on ingrediensliste.Value instead of just the field?

 

Imar

 
Morten Bengtson
 
Merethe Nielsen
Reply

Hi,

You should use @EndIf(YourTag) like in this example (and no pace between End and If like Morten wrote

 

<!--@If Defined(Global:Extranet.UserName)-->
    You are logged in as:<br />
    <strong><!--@Global:Extranet.Name--></strong>

<!--@EndIf(Global:Extranet.UserName)--">!--@EndIf(Global:Extranet.UserName)-->

 

http://templates.dynamicweb.com/TemplateTags/Dynamicweb-template-tags/General-tags/If-Defined.aspx

 

Kind regards,
Merethe

 
Morten Bengtson
Reply

FYI... The tag name is not required in the EndIf

<!--@If Defined(Global:Extranet.UserName)-->

You are logged in as:<br />

<strong><!--@Global:Extranet.Name--></strong>

<!--@EndIf-->

 

You must be logged in to post in the forum