fn:substring(string,start,len)
fn:substring(string,start)
Returns the substring from the start position to
the
specified length. Index of the first character is 1. If length is
omitted it
returns the substring from the start position to the end
The above code-snippet would give you the first 10 characters of the title-field on the current page, and in the end automatically insert three dots (...).
You could try to play around with the function if it fits your needs.
Which version of Umbraco are you using? If you are using one of the newer versions (4.5+) you're probably using the new XML shcema. Then you should do like this:
How get only a few characters of a string in xslt?
How get only a few characters of a string in xslt?
Example, get only 10 characters of a title.
Thnaks
Hi Bruno
xslt substring, as seen at http://www.w3schools.com/xpath/xpath_functions.asp
----
fn:substring(string,start,len)
fn:substring(string,start) Returns the substring from the start position to the specified length. Index of the first character is 1. If length is omitted it returns the substring from the start position to the end
Example: substring('Beatles',1,4)
Result: 'Beat'
Example: substring('Beatles',2)
Result: 'eatles'
----
Dan
Hi Bruno
You could try out the umbraco.library:TruncateString-function. E.g:
The above code-snippet would give you the first 10 characters of the title-field on the current page, and in the end automatically insert three dots (...).
You could try to play around with the function if it fits your needs.
/Kim A
Thanks a lot Dan ;)
Thanks a lot to Kim A.
I´m sure that your answer will help me. Thanks
Thanks Kim,
This was just what I was after :)
Sam.
Hello,
If you really need to be the clever enough, use ucomponents and let the GetFirstWords xslt function to do the job
ucomponents.strings:GetFirstWords(,,)
that works better for short description
Cheers, Giorgos
<xsl:value-of select="substring(string,startlocation,length)"/>
no need to call any umbraco function
Hi Kim,
I have tried this in my XSLT but nothing is showing up.
Hi Fuji
Which version of Umbraco are you using? If you are using one of the newer versions (4.5+) you're probably using the new XML shcema. Then you should do like this:
If this doesn't work, could you make sure that the current page has a property with an alias of eventTitle, and that this field is not empty?
Does it help?
/Kim A
Hi Kim,
Yes am using new schema v4.7...and got it working like this instead
//fuji
But thanks for replying and for the support
//fuji
Ahh okay, so you're inside some kind of loop then right? Either a for-each or an apply-templates since you don't need the $currentPage.
But cool that you got it sorted out Fuji :)
/Kim A
You're right...the struture changed during the course of the project .....but in the end its working.
//fuji
is working on a reply...