Copied to clipboard

Flag this post as spam?

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


  • Barry 99 posts 187 karma points
    Aug 16, 2009 @ 18:09
    Barry
    0

    XSLT filter date

    I have this select in my XSLT

       <xsl:for-each select="$currentPage/ancestor-or-self::node//node [@nodeTypeAlias ='eventList']/node">
            

    I'd like to additionally filter this by eventDate - where the eventDate must be greater or equal to today.

    Any ideas on the syntax for this?

  • Tommy Poulsen 514 posts 708 karma points
    Aug 16, 2009 @ 18:35
    Tommy Poulsen
    1

    from the top of my head, something like this (I wrote enetdate as a variable - I dunno how you access it)

    <xsl:for-each select="$currentPage/ancestor-or-self::node//node [@nodeTypeAlias ='eventList']/node [umbraco.library:DateGreaterThanToday($eventDate)]">

     

    >Tommy

  • Chris Koiak 700 posts 2626 karma points
    Aug 16, 2009 @ 19:04
    Chris Koiak
    100

    Hi Barry,

    Just expanding on Tommy's suggestion...

    <xsl:variable name="eventListId" select="1045"/> <!-- CHANGE THE VALUE --> 
    <xsl:variable name="dateAlias" select="updatedon"/> <!-- CHANGE THE VALUE -->

    <xsl:for-each select="$currentPage/ancestor-or-self::node[@level=1]//node [@id=$eventListId]/node [umbraco.library:DateGreaterThanOrEqualToday(data[@alias=$dateAlias)]>
    </xsl:for-each>

    I've changed the xpath to search for eventListId based on it's Id, as well as retricting the ancestor nodes that it will check. Just change the dataAlias variable to the alias of the pages date property.

    If you just want to filter based on the pages default created date then use

    <xsl:for-each select="$currentPage/ancestor-or-self::node[@level=1]//node [@id=$eventListId]/node [umbraco.library:DateGreaterThanOrEqualToday(@createDate)]>
    </xsl:for-each>

    Cheers,

    Chris

  • Barry 99 posts 187 karma points
    Aug 16, 2009 @ 19:05
    Barry
    0

    <xsl:for-each select="$currentPage/ancestor-or-self::node//node [@nodeTypeAlias ='eventList']/node [umbraco.library:DateGreaterThanToday(data [@alias='eventDate'])]">

     

    That worked , thanks Tommy

Please Sign in or register to post replies

Write your reply to:

Draft