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
after seeing this - http://our.umbraco.org/wiki/reference/xslt/snippets/date---add-'th,-st,-rd,-nd'-extension - I tried to adapt it to my specific use, but it's not working.
I have the array as above
<xsl:variable name="endings" select="umbraco.library:Split('st,nd,rd,th,th,th,th,th,th,th,th,th,th,th,th,th,th,th,th,th,st,nd,rd,th,th,th,th,th,th,th,st',',')"/>and then my code (just the bit to get the "th" etc) which is in a for-each loop<xsl:value-of select="$endings/value[number(./data [@alias = 'CalendarItemDay'])]/text()" /> but nothing is returned. "CalendarItemDay" is a numeric datatype with values such as 3, 23, etc. This line displays the day value correctly <xsl:value-of select="./data [@alias = 'CalendarItemDay']"/> Any ideas?
and then my code (just the bit to get the "th" etc) which is in a for-each loop
<xsl:value-of select="$endings/value[number(./data [@alias = 'CalendarItemDay'])]/text()" />
but nothing is returned. "CalendarItemDay" is a numeric datatype with values such as 3, 23, etc.
This line displays the day value correctly
<xsl:value-of select="./data [@alias = 'CalendarItemDay']"/>
Any ideas?
Strange. Try sticking the CalendarItemDay in a variable first and see if it works like that.
<xsl:variable name="dayNumber" select="number(./data [@alias = 'CalendarItemDay'])" />
It might be that the conversion to a number fails at some point, so make sure to try and output the $dayNumber var during debugging as well.
Another idea if to stick just a number in the value, like:
<xsl:value-of select="$endings/value[3]/text()" />
Just to make sure the error is not in the array.
Very strange indeed! Putting the value of "CalendarItemDay" into a variable and using that variable to select the required array item worked!
The strange thing is, I thought you couldn't reassign a value to a variable once it was declared!? The code is in a for-each loop.
Anyway, it is working now, thank you.
It's not reassigned, after each loop the variable is destroyed and recreated. :-) Glad it's fixed!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Problem using an array
after seeing this - http://our.umbraco.org/wiki/reference/xslt/snippets/date---add-'th,-st,-rd,-nd'-extension - I tried to adapt it to my specific use, but it's not working.
I have the array as above
Strange. Try sticking the CalendarItemDay in a variable first and see if it works like that.
It might be that the conversion to a number fails at some point, so make sure to try and output the $dayNumber var during debugging as well.
Another idea if to stick just a number in the value, like:
Just to make sure the error is not in the array.
Very strange indeed! Putting the value of "CalendarItemDay" into a variable and using that variable to select the required array item worked!
The strange thing is, I thought you couldn't reassign a value to a variable once it was declared!? The code is in a for-each loop.
Anyway, it is working now, thank you.
It's not reassigned, after each loop the variable is destroyed and recreated. :-) Glad it's fixed!
is working on a reply...