If Defined

Summary

If/else tags provide a way of outputting conditional information. The template functionality lets you use an If defined tag and an If Not Defined tag. Within both tags you can insert tags valid for the current context (except global tags which can be used everywhere).

If a template tag has a value or does exist, the values within the If Defined tag will be displayed. Otherwise the value within the If Not defined tag will be displayed. Both tags can be used seperately.

Remarks

  • Notice that the If tags has to end with an EndIf tag in order to work. 
  • @Else is available from version 8.2.1.2.

Example of usage

The following example illustrates how to use the If tags in a template:

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

 

<!--@If Not Defined(Global:Extranet.UserName)-->
    <!--@Include(../Extranet/Login.html)-->
<!--@EndIf(Global:Extranet.UserName)-->
<!--@If Defined(Ecom:Product.ImageLarge.Clean)-->There is a large image
<!--@Else-->no image
<!--@EndIf(Ecom:Product.ImageLarge.Clean)-->



<!--@If Not Defined(Ecom:Product.ImageLarge.Clean)--> no image
<!--@Else-->nothing
<!--@EndIf(Ecom:Product.ImageLarge.Clean)-->
 

See also

Read about If LoopDefined or If statements.