The mgiConditional Tag
Tag Behavior
The mgiConditional tag performs a conditional comparison and
displays a result based upon the outcome of the comparison.
Tag Syntax
The mgiConditional tag has two required parameters and six
optional parameters. The tag form is:
<mgiConditional id="Tag ID" lhs="Comparison Value"
relationship="Relationship" rhs="Comparison Value" not="Yes/No"
caseSensitive="Yes/No">
...Body Value 1 - Text, HTML, or MGI Tags...
<mgielse id="Tag ID">
...Body Value 2 - Text, HTML, or MGI Tags...
</mgiConditional>
or
<mgiConditional lhs="Comparison Value" relationship="Relationship"
rhs="Comparison Value" then="True Value" else="False Value"
not="Yes/No" caseSensitive="Yes/No">
</mgiConditional>
Required Parameters:
- lhs="Comparison Value" where "Comparison
Value" is the first value tested in the conditional comparison.
The lhs parameter must contain a decimal number for the relationships
greaterThan, greaterThanOrEqualTo, lessThan, and lessThanOrEqualTo.
- relationship="Relationship" where "Relationship"
is the type of comparison to perform. Valid relationships: equals,
doesNotEqual, greaterThan, greaterThanOrEqualTo, lessThan, lessThanOrEqualTo,
contains, doesNotContain, beginsWith, doesNotBeginWith, endsWith,
doesNotEndWith, isEmpty, and isNotEmpty.
Optional Parameters:
- rhs="Comparison Value" where "Comparison
Value" is the second value tested in the conditional comparison.
The lhs parameter must contain a decimal number for the relationships
greaterThan, greaterThanOrEqualTo, lessThan, and lessThanOrEqualTo.
The rhs parameter is required for the relationships
equals, doesNotEqual, greaterThan, greaterThanOrEqualTo, lessThan,
lessThanOrEqualTo, contains, doesNotContain, beginsWith, doesNotBeginWith,
endsWith and doesNotEndWith.
- not="Yes/No" where "Yes" indicates
that the comparison outcome is reversed such that a true comparison
renders the "else" value and a false comparison renders
the "then" value. "No" indicates that the
comparison outcome is not reversed. The default value is "No".
- caseSensitive="Yes/No" where "Yes"
indicates that the comparison is evaluated with regard to the
capitalization of the lhs and rhs values and "No" inidicates
that the comparison is not evaluated with regard to the capitalization
of the lhs and rhs values. The default value is "No".
- then="True Value" where "True Value"
is the text displayed if the conditional comparison is true.
If the "then" parameter is present
and the mgiConditional tag is not embedded in another MGI tag,
the closing mgiConditional tag is required.
- else="False Value" where "False Value"
is the text displayed if the conditional comparison is false.
If the "else" parameter is present
and the mgiConditional tag is not embedded in another MGI tag,
the closing mgiConditional tag is required.
- id="Tag ID" where "Tag ID" is
a unique string that identifies the mgiConditional tag that is
associated with the mgiElse tag. The id
parameter must be included in the beginning mgiConditional tag
and its associated mgiElse tag if the mgiConditional tags are
nested.
Example Usage and Output
<mgiConditional lhs={mgiGet name="Score"} relationship="greaterThan" rhs="10">
You tend to be conservative in your politics.
<mgiElse>
you tend to be liberal in your politics.
</mgiConditional>
In this example, a survey score is calculated and placed in
a variable. A comparison is performed between the embedded survey
score and a pre-determined value (10). If the survey score is
greater than 10, then the sentence"You tend to be conservative
in your politics" is displayed. If the survey score is less
than or equal to 10, then the sentence "You tend to be liberal
in your politics" is displayed.=
<mgiConditional lhs={mgiFieldContent name="EmailAddress"}
relationship="doesNotContain" rhs="@" then="Error. Please click the back
button on your browser and check your email address.">
In this example, the value of a posted value from a form is
checked for the at sign (@). If the @ character does not exist,
then the message "Error. Please click the back button on
your browser and check your email address." is displayed.
If the @ character does exist, nothing is displayed.
Suggested Usage
|