Copied to clipboard

Flag this post as spam?

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


  • DieterDP 9 posts 22 karma points
    Oct 30, 2009 @ 18:53
    DieterDP
    0

    Trying to make a 'latest updates' script

    Hi all,

    Im trying to make a macro that will display the latest X pages that have received updates. The hard part I'm having is to make this work correctly with umbraco nodes that do not have a pageview themselves (eg: 2 nodes that help decide the content of the parent node - if one of the child nodes is updated, I'd like to have the parent node be labeled as updated).

    This is what I got so far:

    <xsl:for-each select="$currentPage/ancestor-or-self::node[@level=1]/descendant-or-self::node[string(data [@alias='umbracoNaviHide']) != '1']">
        <xsl:sort select="@updateDate" order="descending"/>

    <xsl:variable name="parent_with_page" select="ancestor-or-self::node[@template != 0][1]"/>

    </xsl:for-each>

    The problem here is that duplicates will appear if multiple of the child nodes (that dont have their own template) have been recently updated.

    Eg: if node Parent has 2 childnodes A and B that have been updated recently, the Parent-node will appear in the list 2 times.

  • DieterDP 9 posts 22 karma points
    Oct 30, 2009 @ 21:38
    DieterDP
    0

    After alot of experimenting, I came up with a solution which seems to do its job quite well, I'll post it here for reference.

    If anyone has any suggestions/improvements, please let them know.

    <ul id="LatestUpdates">


    <xsl:for-each select="$currentPage/ancestor-or-self::node[@level=1]/descendant-or-self::node[string(data [@alias='umbracoNaviHide']) != '1' and not(@nodeTypeAlias = 'Inschrijving' or @nodeTypeAlias = 'Photo')]">
    <xsl:sort select="@updateDate" order="descending"/>

    <!-- We move up the tree, looking for the first node that is displayable as a page -->
    <xsl:variable name="page" select="ancestor-or-self::node[@template != 0][1]"/>

    <!-- In this page-node, we find the most recent updateDate and store it -->
    <xsl:variable name="page_latest_update">
    <xsl:for-each select="$page/descendant-or-self::node[./ancestor-or-self::node[@template != 0][1]/@id = $page/@id]">
    <xsl:sort order="descending" select="@updateDate"/>
    <xsl:if test="position()=1"><xsl:value-of select="@updateDate"/></xsl:if>
    </xsl:for-each>
    </xsl:variable>


    <xsl:if test="@updateDate = $page_latest_update">
    <li><xsl:value-of select="umbraco.library:FormatDateTime(@updateDate, 'dd/MM/yy')"/> - <a href="{umbraco.library:NiceUrl($page/@id)}"><xsl:value-of select="$page/data [@alias = 'PageHeader']"/></a></li>
    </xsl:if>

    </xsl:for-each>


    </ul>
  • 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