Developer manual

if

Checks the contents of the field specified in the 'id' attribute and returns the contents inside the 'if' tag.

Updated: Type: springtag

Method

<if attribute="value">result</if>

Current Experimental

Request Attributes

  Attribute Type Description Default Required?
current id string The id of the field to check the value of. Yes
current value list The value(s) to check for positive match
• You can specify multiple values by separating them with a space.
• You can check if a field is empty by using 'null'
• Can not be used with 'not'
No
current not list The value(s) to check for negative match
• You can specify multiple values by separating them with a space.
• You can check if a field is not empty by using 'null'
• Can not be used with 'value'
No
current source option Determines the source xml to check
Allowed values: session, navigation
-Current Page- No
experimental node string Name of the parent node in the xml to return the result from
If not set, the first instance of the field value will be returned. Currently only works when /source/session is used.
No

Examples

#1

Request

<if id="title">
    <h1>Welcome</h1>
</if>

If the current page has a field called 'title', and that field is not empty, Spring will return the content inside the if tag.

Response

<h1>Welcome</h1>

#2

Request

<if id="title" value="home">
    <h1>Welcome to our home page</h1>
</if>

If the current page has a field called 'title' with a value of 'home', Spring will return the content inside the if tag.

Response

<h1>Welcome to our home page</h1>

#3

Request

<if id="title" not="home">
    <h1>On this page:</h1>
</if>

If the current page has a field called 'title' with a value which is NOT 'home', Spring will return the content inside the if tag.

Response

<h1>On this page:</h1>

#4

Request

<if id="html" value="null">
    <p><strong>This will only appear if 'html' is empty (null)</strong></p>
</if>

If the current page has a field called 'html' with is empty, Spring will return the content inside the if tag.

Response

<p><strong>This will only appear if 'html' is empty (null)</strong></p>

#5

Request

<if id="pageid" value="springtag-if spring-tags-if">
    <p><strong>Success</strong></p>
</if>

You can specify multiple 'values' for an <if> SpringTag by separating the values with a space

Response

<p><strong>Success</strong></p>

#6

Request

When the session data contains:
<session>
    <temporary>
        <eway>
            <ewaytrxnstatus>True</ewaytrxnstatus>
        </eway>
    </temporary>
</session>
The following in layout.xml:
<if id="ewaytrxnstatus" source="session" node="temporary" value="True" >
    <p>Success</p>
</if>

If the session xml has the

Response

<p>Success</p>

#7

Request

<if id="layout" value="iphone" source="session">
    <p>
      <strong>Session says you are on an iphone!</strong>
    </p>
</if>

Display the contents of the if tag if the <layout>iphone</layout> is set for the session.

#8

Request

<if id="useragentversion" value="iPad" node="/">
    <p>
        <strong>Page XML says you are on an iPad!</strong>
    </p>
</if>

Display the contents of the if tag if <useragentversion>iPad</useragentversion> is set in the page xml.

Multiple 'if' value success