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
I want to hide nodes which aren't updated in 14 days from the current date. Can this be done with XSLT?
Seems I can't update my own post.
I've tried to use umbraco.library:dateDiff but then I get an error: System.FormatException: String was not recognized as a valid DateTime.
version="1.0" encoding="UTF-8"?>DOCTYPE xsl:stylesheet [ ENTITY nbsp " "> ]><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "><xsl:output method="xml" omit-xml-declaration="yes"/><xsl:param name="currentPage"/> <xsl:variable name="currentDate" select="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(),'MMMM d, yyyy')"/> <xsl:variable name="updated" select="umbraco.library:FormatDateTime($currentPage/@updateDate, 'MMMM d, yyyy')"/> <xsl:template match="/"> <xsl:value-of select="umbraco.library:DateDiff('$currentDate', '$updated', 's')"/>xsl:template>xsl:stylesheet>
What am I doing wrong?
Thanks,
Ralp
Found it!
<xsl:param name="currentPage"/> <xsl:variable name="currentDate" select="umbraco.library:CurrentDate()"/> <xsl:variable name="updated" select="$currentPage/@updateDate"/> <xsl:variable name="difference" select="Exslt.ExsltDatesAndTimes:seconds(Exslt.ExsltDatesAndTimes:difference(umbraco.library:FormatDateTime($updated, 'yyyy-MM-dd') , Exslt.ExsltDatesAndTimes:date())) div 86400"/> <xsl:template match="/"> <xsl:choose> <xsl:when test="$difference >= 1"> show'm </xsl:when> <xsl:otherwise> hide'm </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Hide nodes which haven't been updated
I want to hide nodes which aren't updated in 14 days from the current date. Can this be done with XSLT?
Seems I can't update my own post.
I've tried to use umbraco.library:dateDiff but then I get an error: System.FormatException: String was not recognized as a valid DateTime.
version="1.0" encoding="UTF-8"?>
DOCTYPE xsl:stylesheet [ ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="currentDate" select="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(),'MMMM d, yyyy')"/>
<xsl:variable name="updated" select="umbraco.library:FormatDateTime($currentPage/@updateDate, 'MMMM d, yyyy')"/>
<xsl:template match="/">
<xsl:value-of select="umbraco.library:DateDiff('$currentDate', '$updated', 's')"/>
xsl:template>
xsl:stylesheet>
What am I doing wrong?
Thanks,
Ralp
Found it!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.