I believe this can be done, but can't find anything to work for me.
I want my truncated HTML to finish at the end of a word instead of halfway into a word. I think it would work by first calculating the number of characters, then finishing at a space " " instead of the last character.
So in the above example it would display the first 40 HTML characters from mainContent, and finish on a space, or before a comma, period, hyphen or any other nominated characters.
So instead of : We will build the new $13m Sport, Rec... (40 characters)
It would be: We will build the new $13m Sport... (35 characters)
Truncate HTML to finish at the end of a word.
I believe this can be done, but can't find anything to work for me.
I want my truncated HTML to finish at the end of a word instead of halfway into a word. I think it would work by first calculating the number of characters, then finishing at a space " " instead of the last character.
So in the above example it would display the first 40 HTML characters from mainContent, and finish on a space, or before a comma, period, hyphen or any other nominated characters.
So instead of :
We will build the new $13m Sport, Rec... (40 characters)
It would be:
We will build the new $13m Sport... (35 characters)
Has anyone got a solution to this?
Cheers,
JV
Hi JV,
There is an XSLT extension called "GetFirstWords" in uComponents.
http://ucomponents.codeplex.com/wikipage?title=Strings
You can select the number of words to use, and the appender string at the end - which defaults to "..."
This function doesn't strip any HTML, so remember to call "umbraco.library:StripHtml" first.
Cheers, Lee.
is working on a reply...