The double slash is just shorthand for the descendant:: axis - If your EventPage documents are all children of $currentPage, you should of course use a single slash instead. The double slash is very inefficient because the processor searches *every* level below for matches.
Just for completion, i've got it at 1:00am in morning.
<xsl:template match="/">
<!-- (Only use events that have something in the fromDate field) --> <xsl:variable name="events" select="$currentPage//EventPage [normalize-space(eventDates/items/item/fromDate)]" /> <xsl:variable name="fromDate" select="umbraco.library:CurrentDate()" /> <xsl:variable name="toDate" select="GetDays:GetToDate()" /> <xsl:variable name="validEvents" select="$events [(umbraco.library:DateGreaterThanOrEqual($fromDate, eventDates/items/item/fromDate) and umbraco.library:DateGreaterThanOrEqual(eventDates/items/item/toDate, $fromDate)) or (umbraco.library:DateGreaterThanOrEqual($toDate, eventDates/items/item/fromDate) and umbraco.library:DateGreaterThanOrEqual(eventDates/items/item/toDate, $toDate)) or (umbraco.library:DateGreaterThanOrEqual(eventDates/items/item/fromDate, $fromDate) and umbraco.library:DateGreaterThanOrEqual($toDate, eventDates/items/item/toDate)) or (umbraco.library:DateGreaterThanOrEqual($fromDate, eventDates/items/item/fromDate) and umbraco.library:DateGreaterThanOrEqual(eventDates/items/item/toDate, $toDate))]" /> <xsl:copy-of select="$validEvents" /> </xsl:template>
Data Grid XSLT Query
I have a data grid that stores from - to date combinations. I'm trying to bring this back into a variable so that i can work with the data
<xsl:variable name="root" select="$currentPage/descendant::EventPage [@isDoc]" />
<xsl:variable name="events" select="$root [Exslt.ExsltDatesAndTimes:datetime(eventDates/items/item/fromDate) < umbraco.library:CurrentDate()]" />
Any help would be appreciated
Hi Craig,
You should have a look at the DateGreaterThan extension - e.g.:
Alternatively, you can look for a matching extension in the uComponents Date extensions...
/Chriztian
Hi Chriztian,
Really appreciate, your feedback and help. Will take a look at this later when i get home. Also the date extensions option looks good.
Thanks
Hi Chriztian,
Sorry to bother you but I'm trying your code and it won't bring back results
Should this be
The only way i can get anything into copy-of is $eventsRoot/* ?
Hi Craig - no worries :-)
I may just not have enough info about your setup - the way I'm guessing right now was this:
But the naming may just have me fooled - if all your event pages are of the EvenPage document type, then you should do this:
If that's not the case - could you maybe paste some of the copy-of output, so we can grok your structure?
/Chriztian
Perfect and fantastic response :)
Sorry just inquisitive, still really getting to grips with XSLT, but you have $currentPage//EventPage, why the double "/" ?
This works though
The double slash is just shorthand for the descendant:: axis - If your EventPage documents are all children of $currentPage, you should of course use a single slash instead. The double slash is very inefficient because the processor searches *every* level below for matches.
/Chriztian
Just for completion, i've got it at 1:00am in morning.
<xsl:template match="/">
<!-- (Only use events that have something in the fromDate field) -->
<xsl:variable name="events" select="$currentPage//EventPage [normalize-space(eventDates/items/item/fromDate)]" />
<xsl:variable name="fromDate" select="umbraco.library:CurrentDate()" />
<xsl:variable name="toDate" select="GetDays:GetToDate()" />
<xsl:variable name="validEvents" select="$events [(umbraco.library:DateGreaterThanOrEqual($fromDate, eventDates/items/item/fromDate) and umbraco.library:DateGreaterThanOrEqual(eventDates/items/item/toDate, $fromDate)) or
(umbraco.library:DateGreaterThanOrEqual($toDate, eventDates/items/item/fromDate) and umbraco.library:DateGreaterThanOrEqual(eventDates/items/item/toDate, $toDate)) or
(umbraco.library:DateGreaterThanOrEqual(eventDates/items/item/fromDate, $fromDate) and umbraco.library:DateGreaterThanOrEqual($toDate, eventDates/items/item/toDate)) or
(umbraco.library:DateGreaterThanOrEqual($fromDate, eventDates/items/item/fromDate) and umbraco.library:DateGreaterThanOrEqual(eventDates/items/item/toDate, $toDate))]" />
<xsl:copy-of select="$validEvents" />
</xsl:template>
<msxml:script language="C#" implements-prefix="GetDays">
<msxml:using namespace="system" />
public static DateTime GetToDate()
{
var date = DateTime.Parse(DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month).ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString() + " 23:59:59");
return date;
}
</msxml:script>
is working on a reply...