Print a DOM-Substring as plain text

bohm
I'm new here
3 2 671

Sometimes it is desired to display the beginning sequence of an article (e.g. on an overview page).

If the article itself was written using the DOM-editor, this is the way to do it:

$CMS_SET(text, st_domtext.toText(false).substring(0, 100))$

$CMS_VALUE(text.substring(0,  text.lastIndexOf(" ")))$

the method "toText(false)" returns the contents of the DOM-editor als plain text. The example above renders the first 100 characters of the contents of the DOM-editor but will not truncate in the middle of a word.

2 Comments
Version history
Last update:
‎06-21-2010 03:35 AM
Updated by: