Copied to clipboard

Flag this post as spam?

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


  • Sajid Riaz 142 posts 165 karma points
    Jul 17, 2010 @ 12:46
    Sajid Riaz
    0

    dynamic xslt menu version 4.5

    Hi everyone,

    I've picked this xslt up from this link: http://stackoverflow.com/questions/308219/building-a-multi-level-menu-for-umbraco-using-xslt

    I've converted to version 4.5.

    but cannot get to work,  It basically builds a menu system based on a parameter of sub levels  you want it to build.

    can anyone help me get it working?

     

    <?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <!-- update this variable on how deep your menu should be -->
    <xsl:variable name="maxLevelForMenu" select="4"/>
    <!-- match the document root -->
    <xsl:template match="/">
      <div id="nav">
        <xsl:call-template name="SubTree" />
      </div>
    </xsl:template>

     
       <!-- this will be called by xsl:apply-templates -->
    <xsl:template match="* [@isDoc]">
      <!-- the node is either protected, or the user is logged on (no need to check for IsProtected twice) -->
      <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or umbraco.library:IsLoggedOn() = 1">
        <li>
          <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
          <xsl:call-template name="SubTree" />
        </li>
      </xsl:if>
    </xsl:template>   

      <xsl:template name="SubTree">
      <!-- render sub-tree only if there are any child nodes -->
      <xsl:if test="* [@isDoc]">
        <ul>
          <xsl:apply-templates select="* [@isDoc][umbracoNaviHide != '1'][@level &lt;= $maxLevelForMenu]">
            <!-- ensure sorted output of the child nodes -->
            <xsl:sort select="@sortOrder" data-type="number" />
          </xsl:apply-templates>
        </ul>
      </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

  • 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