Which i got from another post here on the forum, but it doesn't seem to be working for me.Sorry I've just start working with xslt and still trying to learn the ins and outs of it.
Is it possible to expanded your solution, with a delimiter. I.e. a full stop. I would like to grab x number of characters. If the last character is not a full stop, go back down the string and cut of at the first full stop. Done, a similiar thing in a usercontrol, but wondered if it was possible in an xslt.
It's not possible with the built in library methods, but you could definatley create an XSLT extension library of your own and create a method to what you are looking for. If you have a method, it might be worth getting in touch with the uComponents guys as they have some handy extension methods, so could be handy to add it.
As Matt mentions, we've got all sorts of string-based functions in uComponents XSLT extensions; including one called "GetFirstWords", which will truncate the string after so many words, take a look:
Displaying first 100 characters in a description
I'm trying to get the first 100 characters from a product description[richtextbox name productDesc] I'm using
<xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(./data[@alias = 'productDesc']), 100,'...')"/>
Which i got from another post here on the forum, but it doesn't seem to be working for me.Sorry I've just start working with xslt and still trying to learn the ins and outs of it.
Try this
I think you should also use disable-output-escaping="yes"
Thanks Dimitris, but that seems to output only the '...'
Hi Ivor,
Are you using Umbraco 4.5 by any chance? If so you'll probably want to change it to:
Matt
Hi Mat,
Thanks! that worked.
Hi Matt
Is it possible to expanded your solution, with a delimiter. I.e. a full stop. I would like to grab x number of characters. If the last character is not a full stop, go back down the string and cut of at the first full stop. Done, a similiar thing in a usercontrol, but wondered if it was possible in an xslt.
Thanks again
Eddie
Hi Eddie,
It's not possible with the built in library methods, but you could definatley create an XSLT extension library of your own and create a method to what you are looking for. If you have a method, it might be worth getting in touch with the uComponents guys as they have some handy extension methods, so could be handy to add it.
Matt
Hi Eddie,
As Matt mentions, we've got all sorts of string-based functions in uComponents XSLT extensions; including one called "GetFirstWords", which will truncate the string after so many words, take a look:
http://ucomponents.codeplex.com/SourceControl/changeset/view/67046#1411983
If you do have any killer code snippets that you'd like to see in uComponents, please let us know!
Cheers, Lee.
is working on a reply...