CSP and HTML Tag Reference
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   

Delimits an IF block.
General Attributes
Attribute Description Value
CONDITION A runtime COS expression to be evaluated. A server-side expression.
The CSP:IF tag displays its contents if the server–side expression specified by the CONDITION attribute evaluates to TRUE at runtime.
A CSP:IF tag must have a CONDITION attribute.
You can specify additional execution paths using the CSP:ELSEIF and CSP:ELSE tags.
You can nest CSP:IF tags:
  <VAR>a</VAR> = 10 and <VAR>b</VAR> = 20.
CSP:IF Examples
The following displays different messages depending on the NAME URL parameter (obtained via the %CSP.Request object):
<CSP:IF CONDITION='$G(%request.Data("NAME",1))="John"'>
Welcome, John!
<CSP:ELSEIF CONDITION='$G(%request.Data("NAME",1))="Jane"'>
Welcome, Jane!
Welcome, whoever you are!
The following example tests if the %session object contains a value for USERNAME . If not it places an error message on the document:
<CSP:IF CONDITION='(%session.Get("USERNAME")="")'>
        Unauthorized Access!
Specifying Script Language
The CSP:IF tag will fire one of two rules depending on whether the language is set to cache or basic; these two rules are %IF and %IFBASIC.