Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Apologies if this has been answered before. I want to display the first 300 characters of a rich text editor and have done the following (which works fine).
<xsl:value-of select="umbraco.library:TruncateString(contents,300,'...')" disable-output-escaping="yes" />
What I would like to do after this is to strip out all images, styling and links. Is there any way I can grab all the outputted text and the strip out all code so it's just plain text?
The reason I put the disable-output-escaping on in the first place is so I don't get any of the html code being pulled in, but it throws in pictures and links and looks unsightly.
Any help would be much appreciated!
There is also a StripHtml() extension that you could try to combine with TruncateString() (do the stripping first).
(And then remove the disable-output-escaping attribute again)
Hope that helps,
Perfect - exactly what I was looking for.
Updated code for anyone who may need it in the future (not sure if you can combine the two for a neater solution, but this was the method I used):
<xsl:variable name="introtext" select="umbraco.library:StripHtml(contents)" />
<xsl:value-of select="umbraco.library:TruncateString($introtext,300,'...')" />
Thanks as always for the quick response Chriztian!
No worries, Tom :-)
You can combine into a single line, but there's no penalty for creating a variable first - only improves the readability of the second line, IMO.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted