I have node with an eventDate (datepicker). So it returns 2010-12-24 as date. Now, in an xslt file, I'd like to select only eventDate that occurs, say, in 2009.
My code sort the event by date (the newest on top) and shows $numChild maximum number of nodes, but when I try to only have certain year event, it does not work.
What does your event variable look like? Are you formatting it to only output the year? like umbraco.library:FormatDateTime(data [alias = 'eventDate'],'yyyy')
And do you get any errors when you're saving the XSLT? Or du you get an XSLT error when trying to load the page? Saying it does not work is a broad error description. We need some more specific info to be able to help you out mate :-)
On the page where you are running the macro...try adding the ?umbDebugShowTrace=true to the end of the url. Do you get any error messages in here?
Ok, the $numChild variable is set in a macro (number). I don't get any error... it just don't display anything if I add "and $eventDate...". My xslt displays the number of node I asked and sort it correctly if I only use the first condition in <xsl:if test="position() <= $numChild>, but I don't want 2010 events, so I add the "and $eventDate" part and it display nothing...
For the ?umbDebugShowTrace=true, it gives me a blue line with nothing under.
You should just apply the eventDate filter already when selecting nodes to display - you want only nodes from 2009, so make sure that your for-each (or apply-templates) selects only those:
Select certain date
Hi,
I have node with an eventDate (datepicker). So it returns 2010-12-24 as date. Now, in an xslt file, I'd like to select only eventDate that occurs, say, in 2009.
For now,I have something like that :
My code sort the event by date (the newest on top) and shows $numChild maximum number of nodes, but when I try to only have certain year event, it does not work.
Can you help me!
Hi Profiterole
What does your event variable look like? Are you formatting it to only output the year? like umbraco.library:FormatDateTime(data [alias = 'eventDate'],'yyyy')
/Jan
Oh!!! I forgot to set a variable before calling $evenDate!
Hmm...you did'nt get an error on the page then? :-)
But glad you got it solved.
/Jan
So, ok I set this :
<xsl:variable name="eventDate" select="umbraco.library:FormatDateTime(data [alias = 'eventDate'],'yyyy')"/>
but it does not work either
So, ok I set this :
<xsl:variable name="eventDate" select="umbraco.library:FormatDateTime(data [alias = 'eventDate'],'yyyy')"/>
but it does not work either
Sorry for the double post!
Where is the $numChild varaible defined?
And do you get any errors when you're saving the XSLT? Or du you get an XSLT error when trying to load the page? Saying it does not work is a broad error description. We need some more specific info to be able to help you out mate :-)
On the page where you are running the macro...try adding the ?umbDebugShowTrace=true to the end of the url. Do you get any error messages in here?
/Jan
Ok, the $numChild variable is set in a macro (number). I don't get any error... it just don't display anything if I add "and $eventDate...". My xslt displays the number of node I asked and sort it correctly if I only use the first condition in <xsl:if test="position() <= $numChild>, but I don't want 2010 events, so I add the "and $eventDate" part and it display nothing...
For the ?umbDebugShowTrace=true, it gives me a blue line with nothing under.
Is it clearer :)
Maybe try setting the eventDate variable inside the for loop like this:
<xsl:variable name="eventDate" select="umbraco.library:FormatDateTime(current()/eventDate,'yyyy')"/>
or
<xsl:variable name="eventDate" select="umbraco.library:FormatDateTime(current()//eventDate,'yyyy')"/>
Can't remember if you need a double slash or not ;)
Merry xmas!
Hi Profiterole,
You should just apply the eventDate filter already when selecting nodes to display - you want only nodes from 2009, so make sure that your for-each (or apply-templates) selects only those:
<xsl:for-each select="umbraco.library:GetXmlNodeById($albumSource)/node[starts-with(data[@alias = 'eventDate'], '2009')]"> <xsl:sort select="data[@alias = 'eventDate']" data-type="text" order="descending" /> <xsl:if test="position() < $numChild"> <!-- do stuff. --> </xsl:if> </xsl:for-each>
/Chriztian
Wow!! Thank you Chriztian, I was not aware of "starts-with" and now it works perfectly!
is working on a reply...