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
thinking aloud here
I have some nodes that look like this
+ catering + + monday (mealDate = 01/06/2013)+ + + lunch+ + + dinner+ + tueday (mealDate = 02/06/2013)+ + + breakfast+ + + lunch+ + + dinner+ + wednesday (mealDate = 03/06/2013)+ + + breakfast+ + + lunch
where each "day" is a document type with the mealData property that uses the standard umbraco data picker
i want to know the total number of meals that have happened until yesterday
so if today was 2/6/13 the total would be 2
and if today was 3/6/13 the total would be 5
can't quite get my mind around how to write the xpath for this
Hi John
What does your current code look like? And do you need to get the total of all meals or only the meals of each day?
/Jan
Currently this
<xsl:value-of select="count($event/tegsCatering/tegsDay [dayDate='2013-04-02T00:00:00']/tegsMeal)"/>
will give me the total number of meals under a specific date.
So I am strruggling to think of a simple test for dayDate < today
Hi John,
You could use an umbraco XLST extension in your selector to compare dates:
umbraco.library:DateDiff(date, $currentDate, 's') < 0
Where currentDate is something like this:
<xsl:variable name="currentDate" select="umbraco.library:CurrentDate()"/>
And date is your date property.
Does this help?
Perfect :)
What I have working nicely as
<xsl:value-of select="count($event/tegsCatering/tegsDay [umb:DateGreaterThanOrEqualToday(dayDate) = false]/tegsMeal)"/>
Happy days :)
Checking that umb:DateGreaterThanOrEqualToday is false I think will include the meals today, so you may need to do some extra manipulation in there if you don't want todays meals included. It's all in those extension methods though.
I want up to yesterday, so I'm thinking if it excludes today and the future from the count that's what I want :)
If you assume that your API creates the date folders in the correct order, you don't even need to sort by date.
You just start at the date folder you want to go up to (e.g. current) and work around that.
- - past (1)- - past (2)- - current = count(.\parent::*\child::day [position() < current()\meal])- - future
That said doing it by date is probally more robust and easier to read in code.
That XPATH isn't tested, it's just back of reciept nonsense
/Lau
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
count below an xpath
thinking aloud here
I have some nodes that look like this
where each "day" is a document type with the mealData property that uses the standard umbraco data picker
i want to know the total number of meals that have happened until yesterday
so if today was 2/6/13 the total would be 2
and if today was 3/6/13 the total would be 5
can't quite get my mind around how to write the xpath for this
Hi John
What does your current code look like? And do you need to get the total of all meals or only the meals of each day?
/Jan
Currently this
<xsl:value-of select="count($event/tegsCatering/tegsDay [dayDate='2013-04-02T00:00:00']/tegsMeal)"/>
will give me the total number of meals under a specific date.
So I am strruggling to think of a simple test for dayDate < today
Hi John,
You could use an umbraco XLST extension in your selector to compare dates:
Where currentDate is something like this:
And date is your date property.
Does this help?
Perfect :)
What I have working nicely as
<xsl:value-of select="count($event/tegsCatering/tegsDay [umb:DateGreaterThanOrEqualToday(dayDate) = false]/tegsMeal)"/>
Happy days :)
Checking that umb:DateGreaterThanOrEqualToday is false I think will include the meals today, so you may need to do some extra manipulation in there if you don't want todays meals included. It's all in those extension methods though.
I want up to yesterday, so I'm thinking if it excludes today and the future from the count that's what I want :)
If you assume that your API creates the date folders in the correct order, you don't even need to sort by date.
You just start at the date folder you want to go up to (e.g. current) and work around that.
- - past (1)
- - past (2)
- - current = count(.\parent::*\child::day [position() < current()\meal])
- - future
That said doing it by date is probally more robust and easier to read in code.
That XPATH isn't tested, it's just back of reciept nonsense
/Lau
is working on a reply...