WM-If |
|||||||||||||||||||||||||||||||||||||||||||||||||
Syntax
|
[WM-If: Value Operator Value] ...HTML if condition is true... [/WM-If] [WM-If: Value Operator Value ] ...HTML if condition is true... [WM-Else] ...HTML if condition is false... [/WM-If] [WM-If: (Value Operator Value) AND (Value Operator Value) OR (Value Operator Value)] |
||||||||||||||||||||||||||||||||||||||||||||||||
Examples
|
[WM-If: Field: ClientName = David] Hey David! [/WM-If] [WM-If: Field: Age <> ""] This person is [WM-Field: Age] years old. [/WM-If] [WM-If CurrentRecordNumber mod 2] <tr><td bgcolor="gray">Gray Cell Color</td></tr> [WM-Else] <tr><td bgcolor="white">White Cell Color</td></tr> [/WM-If] [WM-If: (Field: Age < 18) OR (Field: Age > 65)] You qualify for a discount [WM-Else] The standard price applies [/WM-If] [WM-If: len(Field: Description) > 200]See link for details.[/WM-If] |
||||||||||||||||||||||||||||||||||||||||||||||||
Description
|
Along with the [WM-Else] and [/WM-If] tags, the [WM-If] tag controls what HTML will included into the generated page. The [WM-Else] tag is optional.
The tag arguments consist of two values compared by an operator. If the operator comparison evaluates to true, the HTML following the [WM-If] is written to the generated page. A space follows the operator, and everything after the operator is treated as the second value. If the comparison value is literal text, do not put quotes around it unless those quotes are present in your data. If the optional [WM-Else] tag is used and the arguments evaluate to false, the HTML between the [WM-Else] and [/WM-If] tags will be written to the page instead. Values can be any of the following:
This table lists all operators in both supported forms:
The mod operator deserves a special note here, being perhaps the least obvious of the operators yet among the most valuable. Mod simply determines whether there is a remainder when you divide the first value by the second. This is useful for determining a series of specific number of records, such as every fourth record or every tenth record. For example if you wanted to have table cells created for each record by the WM-Record tag, but wanted every other record to have a different color, you could use mod to alternate portions of a WM-If tag like this: [WM-Record] [WM-If CurrentRecordNumber mod 2] ...even-numbered records are made from this HTML... [WM-Else] ...odd-numbered records are made from this HTML... [/WM-If] [/WM-Record]
The mod operator is an exception to this rule, as it requires that both values are numbers, and will log an error if an attempt is made to apply it to textual data. If you want to compare two values as dates, you can specify that the operator use a date comparison by adding ":date" to the operator: [WM-If Field: BirthDate >:date 11/22/63] Date values are evaluated according to the format in use on the computer WebMerge is running on. This format is set in the operating system's Date control panel. Multiple CriteriaWith WebMerge v2.4 and later you can specify multiple criteria for evaluation, with each criteria enclosed in parentheses: [WM-If: (Field: Age < 18) OR (Field: Age > 65)] You can have up to 16 criteria, and can use parentheses to force some expressions to evaluate before others (as with alebra, expressions more deeply nested in parentheses will be evaluated first): [WM-If: ((Field: Age < 18) OR (Field: Age > 65)) AND (Field: FrequentFlyer = true)]
Introduced in WebMerge 2.0. |