I have a Rich text editor which has the alias bodyText and using the following systax <p><xsl:value-of select="umbraco.library:TruncateString(./bodyText, 300,'')" disable-output-escaping="yes" /><xsl:text>... </xsl:text> <a class="read-more" href="{umbraco.library:NiceUrl(@id)}" title="read more">read more</a></p>it is pulling 300 characters from the property and displaying it as a snippet text in a list of items.
I was wondering if there was a way in xslt to ignore any new line that is made in the RTE.
I want my list item to look like this
but if the content editor decide to begin a new line it runs the risk of looking like this
The only other way i thought of doing it is creating a new property called teaser text (simple editor) and using uComponents to set a char limit. but i was thinking that the content editor may have to enter the same info twice.
You should be very careful when using string manipulation on the contents of the RTE - remember that it's HTML, so you could very easily end up truncating in the middle of en <em> tag or a link, which could render the rest of the page unusable...
For the newlines, in this case, you could also just use CSS - if you wrap the output in a
Xslt to ignore new line in RTE
Hey all,
I have a Rich text editor which has the alias bodyText and using the following systax
<p><xsl:value-of select="umbraco.library:TruncateString(./bodyText, 300,'')" disable-output-escaping="yes" /><xsl:text>... </xsl:text> <a class="read-more" href="{umbraco.library:NiceUrl(@id)}" title="read more">read more</a></p>
it is pulling 300 characters from the property and displaying it as a snippet text in a list of items.I was wondering if there was a way in xslt to ignore any new line that is made in the RTE.
I want my list item to look like this
but if the content editor decide to begin a new line it runs the risk of looking like this
The only other way i thought of doing it is creating a new property called teaser text (simple editor) and using uComponents to set a char limit. but i was thinking that the content editor may have to enter the same info twice.
Any help would be great thanks
Paul
Hi Paul,
Maybe you could use the library method called umbraco.library:Replace, you can find some documentation about the library method here: http://our.umbraco.org/wiki/reference/umbracolibrary/replace
For the replace part I found inspiration here: http://our.umbraco.org/forum/developers/xslt/9239-Removing-TinyMCE-line-breaks
Hope this helps or can lead you in the right direction,
/Deenis
Hey Dennis thanks for the prompt reply :).
I will use your information as a base to solve the problem in question.
Thanks a lot mate
Paul
Hi Paul,
Good to hear Paul, I think that maybe you can use the code that I provide you, in the previous post.
If it the case, then remember to mark the questions as solved.
/Dennis
Hi Paul,
You should be very careful when using string manipulation on the contents of the RTE - remember that it's HTML, so you could very easily end up truncating in the middle of en
<em>
tag or a link, which could render the rest of the page unusable...For the newlines, in this case, you could also just use CSS - if you wrap the output in a
/Chriztian
Hi Chriztian,
Good point mate I will take that into consideration :) I think the CSS is a good call.
Thanks for the advice mate
Paul
is working on a reply...