Copied to clipboard

Flag this post as spam?

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


  • Craig O'Mahony 363 posts 917 karma points
    Feb 16, 2015 @ 17:50
    Craig O'Mahony
    0

    XSLT Menu displaying out of content order

    Hi all,

    I've got a fairly simple menu that I've used for a while and today I've created another item/page for the menu. I want this item to appear in the middle of the menu so after I'd created the page I used the standard sort functionality in Umbraco to put the page where I want it to appear but new page is appearing at the end of the menu instead of in the middle....

    Here's my XLST 

          <!--
          For each child node of the homeNode that is a document (isDoc)
          and the level is 1
          and the property umbracoNaviHide is NOT 1 (true/checked)
          -->
    <xsl:for-each select="$homeNode/* [@isDoc and @level = 2 and string(umbracoNaviHide) != '1' and string(topLevelNavigationItem) = '1' ]">
            <li>
              <!--
              Add the CSS class 'selected' if the currentPage or parent nodes (up the tree to the root)
              ID matches our current node's ID in the for each loop
              -->
              <xsl:if test="$currentPage/ancestor-or-self::* [@isDoc]/@id = current()/@id">
                <xsl:attribute name="class">
                  <xsl:text>active</xsl:text>
                </xsl:attribute>
              </xsl:if>
              
    <xsl:if test="umbraco.library:HasAccess(@id,@path)">

     <xsl:choose>
     <xsl:when test="$currentPage/ancestor-or-self::* [@isDoc]/@id = current()/@id">
    <a class="active" href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="translate(@nodeName, $smallcase, $uppercase)" />
    </a>
     </xsl:when>
     
     <xsl:otherwise>
    <a href="{umbraco.library:NiceUrl(@id)}">
      <xsl:value-of select="translate(@nodeName, $smallcase, $uppercase)" />
    </a>  
     </xsl:otherwise>  
     
     </xsl:choose>  
    </xsl:if>

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

    And here's a screenshot of the content structure:

    But when the menu displays 'In-house' comes after Blog.

    Any ideas anyone?

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Feb 16, 2015 @ 17:57
    Jan Skovgaard
    100

    Hi Craig

    Have you tried to simply refresh the XML cache by right clicking the "CONTENT" node and choose "Republish" entire site? I it might just be that.

    /Jan

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Feb 16, 2015 @ 17:59
    Chriztian Steinmeier
    3

    Hi Craig,

    This could just be an old publishing bug (don't remember the version, but I had this hit me once in a while on some older sites) - something to do with the XML cache not being totally rebuilt (i.e. reordered correctly) right away.

    Because the XML for the items are updated, there's a way to fix it though, using the sort instruction, sorting on the sortOrder attribute:

    <xsl:for-each select="...">
       <xsl:sort select="@sortOrder" data-type="number" />
      <!-- ... -->
    </xsl:for-each>
    

    /Chriztian

  • Craig O'Mahony 363 posts 917 karma points
    Feb 16, 2015 @ 18:00
    Craig O'Mahony
    0

    That worked a treat!

  • 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