Copied to clipboard

Flag this post as spam?

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


  • Roger Sutton 52 posts 124 karma points
    Feb 15, 2011 @ 17:32
    Roger Sutton
    0

    XSLT showing all previous versions of a document

    Hi,

    I'm trying to get a list of sub items from preceding siblings and am nearly there but the code also gets all earlier versions of the subpages as well.

    Level1
          Page 1
               item A v1 (old) (not visible in content)
               item A v2 (current)
          Page 2
               item B v1 (old) (not visible in content)
               item B v2 (old) (not visible in content)
               item B v3 (current)
          ...
    Page N


    I run my code from Page N and want to see:

               item A v2 (current)
               item B v3 (current)

    But see:

               item A v1 (old)
               item A v2 (current)
               item B v1 (old)
               item B v2 (old)
               item B v3 (current)

    The code fragment is:

    <xsl:for-each select="$currentPage/preceding-sibling::*/child::* [@isDoc][string(umbracoNaviHide) != '1']">
     

    I'm sorry if this is something simple but I can't get my head around it.

    Thanks if you can help.

    Roger

  • Profiterole 232 posts 264 karma points
    Feb 15, 2011 @ 18:01
    Profiterole
    0

    Hi, you could sort by updateDate or createDate and display only the first one.

     

    <xsl:sort select="@updateDate" order="descending" />
        <xsl:if test="position() = 1">
  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Feb 15, 2011 @ 18:08
    Chriztian Steinmeier
    1

    Hi Roger,

    If you're seeing old versions alongside the new ones, there's something wrong with XML cache - are you getting duplicate ID's in the output if you print them (i.e. with the <xsl:value-of /> instruction)? And how about the updateDate ? Try this:

    <xsl:for-each select="$currentPage/preceding-sibling::*/*[@isDoc][not(umbracoNaviHide = 1)]">
        <p>
            <xsl:value-of select="@nodeName" /> (@id = <xsl:value-of select="@id" />) [<xsl:value-of select="@updateDate" />]
        </p>
    </xsl:for-each>

    If you're getting duplicate ID's there's a mouse in your XML cache...

    /Chriztian

  • Roger Sutton 52 posts 124 karma points
    Feb 15, 2011 @ 18:20
    Roger Sutton
    0

    Hi,

    I could check the date and set only the first one but I don't have this problem on other XSLT files. I'm sure it's related to the '/child::* ' element and  with the right syntax it should only list the ones at the top of the version list.

    I have printed the Ids and they are the same for the different versions. Raising the idea of a corrup XML cache does make me think, I have changed the docType definition on these items and maybe they are 'seen' as 2 distinct items, I will test this and get back to you.  

  • Roger Sutton 52 posts 124 karma points
    Feb 15, 2011 @ 18:29
    Roger Sutton
    0

    Hi,

    Thanks guys, it is a corrupt xml cache. The changes I've made in the item docType has generated some 'orphan' versions of the items. Having deleted the items, created new ones and then newer versions I now only see the latest versions. However the orphan versions still appear in the output although they are not in the content. I assume I can clear the XML cache somehow?

    Anyway thanks for replying.

    Roger

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Feb 15, 2011 @ 19:11
    Chriztian Steinmeier
    1

    Hi Roger,

    I once heard that going to /umbraco/dialogs/republish.aspx?xml=true will refresh the XML cache (incl. Media XML) so maybe try that...

    /Chriztian

  • Roger Sutton 52 posts 124 karma points
    Feb 16, 2011 @ 11:16
    Roger Sutton
    0

    You're spot on Chriztian, that worked perfectly. Thanks very much.

  • 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