Copied to clipboard

Flag this post as spam?

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


  • Osiris 4 posts 25 karma points
    Jan 13, 2012 @ 22:37
    Osiris
    0

    Sorting Navigation

    Hey Guys,

    Sorry if this has already been answered, I didnt see anything. I have looked through the navigation XSLT and I see a "sortOrder" property, but see no where to access that? When I sort in the content menu the position of the navigation stays the same. Basically just looking for a way to tell the navigation macro where to place the links.

    -Marc

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Jan 13, 2012 @ 22:51
    Jan Skovgaard
    0

    Hi Marc and welcome to our :)

    When you have sorted the pages in the backoffice you should also refresh the xml cache by going to the root "Content" node, right click on it and select "Republish entire site". When that is done the links on your website should reflect that same sortorder.

    Hope this helps.

    /Jan

  • Osiris 4 posts 25 karma points
    Jan 13, 2012 @ 23:18
    Osiris
    0

    Hey Jan,

    Thank you for the quick reply. I have tried this, but the results are the same. I even sorted 'Home' all the way to 9 and it is still the first in the list.

    -Marc

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Jan 13, 2012 @ 23:38
    Jan Skovgaard
    0

    Hi Osiris

    Hmm, what happens if you try to recycle the app pool? Still the same? What version of Umbraco are you using? And are you generating the navigation with XSLT or Razor?

    /Jan

  • Osiris 4 posts 25 karma points
    Jan 13, 2012 @ 23:43
    Osiris
    0

    Same results after recycling the app pool. This starter kit generated it for you. There is a Navigation macro it uses. Inside the XSLT I see <xsl:sort select="@sortOrder" data-type="number" />. But nothing seems to change? 

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Jan 13, 2012 @ 23:45
    Jan Skovgaard
    0

    What happens if you remove the sort order perhaps? Could you post the whole xslt snippet so I can see the full context. I have an idea about what is going on but would like to see the full context :)

    I assume it's v4.7?

    /Jan

  • Osiris 4 posts 25 karma points
    Jan 13, 2012 @ 23:53
    Osiris
    1

    I found a work around, sort of. If I change the sort order, and make a change to the navigation it seems to update. Here is the XSLT. Is there a code tag on this forum?

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:Stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="msxml umbraco.library">
      <xsl:output method="xml" omit-xml-declaration="yes"/>
      <xsl:param name="currentPage"/>

      <xsl:variable name="CssClassName" select="/macro/CssClassName" />
      <xsl:variable name="CssId" select="/macro/CssId" />

      <xsl:variable name="StopLevel" select="/macro/StopLevel" />
      <xsl:variable name="StartLevel" select="/macro/StartLevel" />

      <xsl:template match="/">
          <xsl:call-template name="Navigation">
            <xsl:with-param name="childNodes" select="$currentPage/ancestor-or-self::*[@isDoc][@level=($StartLevel)]/* [@isDoc][not(name()='Article')][not(umbracoNaviHide=1)]" />
          </xsl:call-template>
      </xsl:template>

      <xsl:template name="Navigation">
        <xsl:param name="childNodes"/>
        <xsl:choose>
        <xsl:when test="count($childNodes) > 0">
          <ul>
            <xsl:if test="$CssId !=''">
              <xsl:attribute name="id">
                <xsl:value-of select="$CssId" />
              </xsl:attribute>
            </xsl:if>
            <xsl:if test="$CssClassName !=''">
              <xsl:attribute name="class">
                <xsl:value-of select="$CssClassName" />
              </xsl:attribute>
            </xsl:if>

            <xsl:for-each select="$childNodes">
              <xsl:call-template name="SubMenu"/>
            </xsl:for-each>
          </ul>
        </xsl:when>
          <xsl:otherwise>
            &nbsp;
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>


      <xsl:template name="SubMenu">
        <xsl:if test="(umbraco.library:IsProtected(current()/@id, current()/@path) = false() or (umbraco.library:HasAccess(current()/@id, current()/@path) = true() ))">
          <li>
            <xsl:attribute name="class">

              <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
                <xsl:text>selected </xsl:text>
              </xsl:if>

              <xsl:if test="position() = 1">
                <xsl:text>first </xsl:text>
              </xsl:if>

              <xsl:if test="position() = last()">
                <xsl:text>last</xsl:text>
              </xsl:if>
            </xsl:attribute>
            <xsl:choose>
              <xsl:when test="string-length(data[@alias='RedirectUrl']) > 0">
                <href="{data[@alias='RedirectUrl']}" title="{@nodeName}">
                  <xsl:value-of select="@nodeName"/>
                </a>
              </xsl:when>
              <xsl:when test="string-length(data[@alias='RedirectPageId']) > 0">
                <href="{umbraco.library:NiceUrl(data[@alias='RedirectPageId'])}" title="{@nodeName}">
                  <xsl:value-of select="@nodeName"/>
                </a>
              </xsl:when>
              <xsl:otherwise>
                <href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}">
                  <xsl:value-of select="@nodeName"/>
                </a>
              </xsl:otherwise>
            </xsl:choose>


            <xsl:if test="current()/@level &lt; ($StopLevel) and $currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
              <xsl:if test="count(*[@isDoc][not(data[@alias='umbracoNaviHide']=1)]) > 0">
                <ul>
                  <xsl:for-each select="*[@isDoc][not(data[@alias='umbracoNaviHide']=1)]">
                    <xsl:sort select="@sortOrder" data-type="number" />
                    <xsl:call-template name="SubMenu"/>
                  </xsl:for-each>
                </ul>
              </xsl:if>
            </xsl:if>

          </li>
        </xsl:if>
      </xsl:template>
    </xsl:stylesheet>

  • Jan Skovgaard 11264 posts 23592 karma points MVP 8x admin c-trib
    Jan 14, 2012 @ 06:48
    Jan Skovgaard
    1

    Hi Osiris

    Good to hear you managed to get it solved.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft