Free-Conversant Support / Message Conditional Macro: msg.body.length
 Home   About Conversant   Free Sites   Hosting   Support   XML-RPC 

Search



Documentation >> Conditionals >> Messages >> body >> msg.body.length

Message Conditional Macro: msg.body.length

Operators:

  • == (equal to)
  • != (not equal to)
  • greaterThan
  • greaterThanOrEqualTo
  • lessThan
  • lessThanOrEqualTo

Usage Notes

  • Tests the length of the body text 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 a message determines whether or not something is displayed. For example, if a message is less than 500 characters long you might want to display the whole thing, but if it's longer you'd prefer to cut the message short and include a link to the full message on another page. (You might want to build such a feature into your weblog item template, after the weblog tool has been updated to support conditional macros.)

Examples

In this example, the second line will be used because this message is more than 350 characters long.

<!--#if condition="msg.body.length <= '350'"-->

1. <!--#msgBody-->

<!--#else-->

2. <!--#msgBody clipLength="250"--><br>
<a href="<!--#msgUrl-->">Continued...</a>

<!--#endIf-->

See the above code in action, here:

2. <!--#msgBody clipLength="250"--><br>
<a href="<!--#msgUrl-->">Continued...</a>

Note that you'd actually use this macro in a template, not in a message, so that it would affect any messages "rendered" through that template. Also, it is not possible to insert a message into itself with the #msgBody macro as shown here, so we've chosen to display the macro itself. Hopefully you won't find this too confusing.

View in DG