Documentation >> Conditionals >> Messages >> Subject >> msg.subject.length
Message Conditional Macro: msg.subject.length
Operators:
- == (equal to)
- != (not equal to)
- greaterThan
- greaterThanOrEqualTo
- lessThan
- lessThanOrEqualTo
Usage Notes
- Tests the length of the subject of the current message, comparing it with the |conditional value| on the right side of the |conditional operator|.
- This is an extremely simple conditional, and is intended for use in places where the length of the subject determines what is displayed. For example, if a subject is less than 60 characters long you might want to display the whole subject, but if it's longer you'd prefer to cut truncate it for design purposes. Such things are often done in search result pages, for example. he message short and include a link to the full message on another page.
Examples
In this example, the first line will be used because this message's is less than 60 characters long.
<!--#if condition="msg.subject.length lessThanOrEqualTo '60'"-->
1. <!--#msgSubject-->
<!--#else-->
2. <!--#msgSubject clipLength="57"-->...
<!--#endIf-->
See the above code in action, here:
1. <!--#msgSubject-->
Note that you'd actually use this in a template, not in a message, so that it would affect any messages "rendered" through that template (using it in a message is pointless, since the macro would only apply to the current message's subject, and you already know the length of the subject).
View in DG
|