Copied to clipboard

Flag this post as spam?

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


  • Dan Christoffersen 64 posts 119 karma points
    Nov 17, 2009 @ 15:36
    Dan Christoffersen
    0

    Listing nodes with date after current date

    I am trying to display a list of nodes with a "displayOnFrontpageUntil" date parameter. Onle nodes with the date set to after current date should be listed.

    How do i go about this?

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Nov 17, 2009 @ 16:04
    Chris Houston
    3

    Hi Dan,

    This might not be the perfect solution, but it will certainly work:

    <xsl:for-each select="$currentPage/node">
    <xsl:if test="substring(string(Exslt.ExsltDatesAndTimes:difference(umbraco.library:CurrentDate(),node/data [@alias='displayOnFrontpageUntil'])),1,1) != '-'">
    <xsl:value-of select="node/data [@alias='bodyText']"/>
    </xsl:if>
    </xsl:for-each>

    Obviously you will need to change the for-each loop to select the appropriate nodes and then change whatever you wish to output in the middle :)

    Cheers,

    Chris

  • dandrayne 1138 posts 2262 karma points
    Nov 17, 2009 @ 16:28
    dandrayne
    0

    There's also the old

    <if test="umbraco.library:DateGreaterThanOrEqualToday( ./data [@alias='theDate'] )">

     

    Dan

  • Dan Christoffersen 64 posts 119 karma points
    Nov 17, 2009 @ 16:30
    Dan Christoffersen
    0

    Great, that works.

  • Dan Christoffersen 64 posts 119 karma points
    Nov 17, 2009 @ 16:33
    Dan Christoffersen
    0

    ups - press the wrong solved button by mistake. Should have been Chris' post.

    Dan Draynes solution makes an error:

    System.FormatException: The string was not recognized as a valid DateTime. There is a unknown word starting at index 0

     

  • dandrayne 1138 posts 2262 karma points
    Nov 17, 2009 @ 17:32
    dandrayne
    0

    Oops!  I've given chris a + to redress the balance.

    Well, seeing as we're going down the wrong road already, both solutions should work fine. The umbraco.library command will only work on a valid datetime - are you using the umbraco datepicker to select your date?

    Dan 

  • Dan Christoffersen 64 posts 119 karma points
    Nov 18, 2009 @ 14:39
    Dan Christoffersen
    0

    yes - the "date picker" data type.

  • dandrayne 1138 posts 2262 karma points
    Nov 18, 2009 @ 14:56
    dandrayne
    1

    Ooh, did you copy and paste my code direct? using

    <if test="umbraco.library:DateGreaterThanOrEqualToday( ./data [@alias='theDate'] )">

    instead of

    <if test="umbraco.library:DateGreaterThanOrEqualToday( ./data [@alias='displayOnFrontpageUntil'] )">

    Dan

     

     

  • Dan Christoffersen 64 posts 119 karma points
    Nov 19, 2009 @ 15:38
    Dan Christoffersen
    0

    Not sure what did wrong before - but have now got it to work with your solution as well.

    Thanks for the help.

    /Dan

  • 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