Documentation >> Conditionals >> Messages >> msg.label >> msg.label.name
Message Conditional Macro: msg.label.name
Operators:
- == (equal to)
- != (not equal to)
- greaterThan
- greaterThanOrEqualTo
- lessThan
- lessThanOrEqualTo
- beginsWith
- endsWith
- contains
Usage Notes
- Tests the name of the label assigned to the current message, comparing it with the |conditional value| on the right side of the |conditional operator|.
- The name of a label is the text that Conversant displays to identify a label. For example, when you edit a message and choose a label from a popup menu (or dropdown list), that list of labels are the names of the available labels.
- The full range of operators can be used with this conditional. Which one you need will, of course, depend on how you've organized your labels.
- Using label names in a conditional macro will be fairly common, but comes with some minor risks for two reasons. First, label names can be changed, so if you change the name of your label you may need to find and adjust your conditionals in your templates. Second, label names are not guaranteed to be unique: it is possible to have two (or more) labels with the same name. Once those risks are understood, though, you'll probably find that working with label names is much more convenient than working with label ID's (see the msg.label.id conditional), as names are easier to remember (and read) than long numbers.
- If a message has not been given a label, the label name is treated as the "empty string": a name with no characters. You can test for this condition by providing an empty |conditional value|. This is done by placing nothing between the two single quotes that delimit the value, as so: ''.
Examples
In this example, the first line will be shown if the message has not been labelled, the second if the message has been labelled with the support site's "Documentation" label, and the third if neither of the previous tests are true.
<!--#if condition="msg.label.name == ''"-->
1. This message has not been given a label.
<!--#elseif condition="msg.label.name == 'Docs'"-->
2. This message has been labelled as documentation.
<!--#else-->
3. This message has a label, but it's not documenation.
<!--#endIf-->
See the above code in action, here:
2. This message has been labelled as documentation.
View in DG
|