<ISSET>
can be used to define and set a user-defined variable.
The first occurrence of <ISSET>
in a template declares and sets the variable, there is no other special tag needed for declaration. In case the variable already exists, <ISSET>
resets it to the specified value.
The special attribute scope
is available to determine the scope of the user-defined variable. The scope
is required and can be either request
(default) or session
.
Session scope
The scope session means that the variable is accessible to all templates during a particular storefront session. The lifetime of a session variable ends with a session. A session variable can be used in expressions and is identified by its simple name. Values can now be of any type, not just Double and String.
Note
Non-serializable objects stored at session scope are not be written to the database when the session is made persistent.
<isset value = "( {String} | {ISML expression} )" name = "{simple name}" scope = "( request | session )" >
The following example shows how <ISSET>
is used to define and initialize a variable named color
. The value of color
is the string #A0CC99
.
<isset scope="request" name="color" value="#'#A0CC99'#">
In the next example, if a variable was already defined by a former <ISSET>
tag (first line), a second <ISSET>
resets the value of the variable (second line):
<isset scope="request" name="counter" value="#0#" > <isset scope="request" name="color" value="#counter + 1#">
Finally, the examples below illustrate the usage of the scope attribute:
<!-- the value goes to the session --> <isset scope="session" name="foo" value="bar"> <!-- the value goes to the pipeline dictionary --> <isset scope="request" name="foo" value="bar">
scope
This attribute is required.
scope = request | session
The default value is request
. Specifies the scope of a user-defined variable. In case of request scope, the value is stored to the pipeline dictionary. In case of session scope, the value is stored to the session.
name
This attribute is required.
name = simple name
Specifies the name of a user-defined variable. Mind the following rules for naming user-defined variables:
value
This attribute is required.
value = ISML Expression
Specifies a value to be stored in the variable. Value can be of any type.
Note
Non-serializable objects stored at session scope are not be written to the database when the session is made persistent.