Copied to clipboard

Flag this post as spam?

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


  • Garry Bain 149 posts 124 karma points
    Jun 04, 2010 @ 10:24
    Garry Bain
    0

    Help with showing latest news item

    Hi everyone,

    I have a piece of xslt which shows my teaser "newsTeaser" field from the latest news item on my site (this appears on every page in a "News panel"). I am having a bit of trouble with it showing the latest news item though. My code is:


    <xsl:for-each select="$currentPage/ancestor-or-self::root//node [string(data [@alias='newsTeaser']) != '' and string(data [@alias='umbracoNaviHide']) != '1' and @nodeTypeAlias='NewsItem' ]">

    <xsl:sort select="current()/data[@alias='newsTeaser']" order="descending" />

    <xsl:if test="position() &lt;= 1">
    <xsl:value-of select="./data [@alias = 'newsTeaser']" disable-output-escaping="yes" />



    <a href="/news.aspx">
    <img src="/images/more.jpg" alt="Read more" id="readmore"/>
    </a>



    </xsl:if>
    </xsl:for-each>

    This code is currently showing my second newest news item though. Both the new ones were created today "4th June" - so I wonder if it can't distinguish between the time they were created?

    Any help would be great.

    Garry.

  • Rich Green 2246 posts 4006 karma points
    Jun 04, 2010 @ 10:29
    Rich Green
    0

    Hi Garry,

    You are sorting on your newsTeaser field, it looks like you want to be sorting on date the node was created (@createDate).

    Best of luck

    Rich

     

     

  • Garry Bain 149 posts 124 karma points
    Jun 04, 2010 @ 12:00
    Garry Bain
    0

    Ah yes, of course.

    Thanks very much Rich!

    Garry.

  • 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