Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ralph van Vugt 57 posts 101 karma points
    Dec 17, 2010 @ 14:51
    Ralph van Vugt
    0

    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?

  • Ralph van Vugt 57 posts 101 karma points
    Dec 17, 2010 @ 15:12
    Ralph van Vugt
    0

    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

  • Ralph van Vugt 57 posts 101 karma points
    Dec 17, 2010 @ 15:52
    Ralph van Vugt
    0

    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 &gt;= 1">
            show'm
          </xsl:when>
          <xsl:otherwise>
            hide'm
          </xsl:otherwise>
        </xsl:choose>
    
    </xsl:template>
    
    </xsl:stylesheet>
  • 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.

Please Sign in or register to post replies