Copied to clipboard

Flag this post as spam?

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


  • Mads Sørensen 188 posts 433 karma points
    Jun 06, 2012 @ 15:04
    Mads Sørensen
    0

    Simple Dropdown Menu

    Hey

    I've tryed to make a simple dropdown menu in xslt, The first level will also output but the second level i can't output.

    <?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"/>

    <!-- Input the documenttype you want here -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">
    <!-- The fun starts here -->
      <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
        <xsl:if test="$currentPage/@id = current()/@id or $currentPage/../@id = current()/@id or $currentPage/../../@id = current()/@id">
          <!-- output navigation Title -->
          <ul>
     
            <!-- MAIN NAVIGATION -->
              <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
              <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"></xsl:if>
              <li>
                <a href="{umbraco.library:NiceUrl(@id)}">
                   <xsl:if test="@id = $currentPage/@id"><xsl:attribute name="class">naviLv2Active</xsl:attribute></xsl:if>
                  <xsl:value-of select="@nodeName"/>
                </a>
              
              <!-- DROP DOWN NAVI  -->
                <xsl:if test="$currentPage/child::* [@isDoc]) &gt; 0 and $currentPage/@id = current()/@id or$currentPage/../@id = current()/@id or $currentPage/../../@id = current()/@id">
              
                  <ul class="dropDownNavi">
                    <xsl:for-each select="./child::* [@isDoc and string(umbracoNaviHide) != '1']">
                    <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"></xsl:if>
                    
                     <li>
                      <a href="{umbraco.library:NiceUrl(@id)}">
                        <xsl:if test="@id = $currentPage/@id"><xsl:attribute name="class">naviLv3Active</xsl:attribute></xsl:if>
                       <xsl:value-of select="@nodeName"/>
                      </a>
                    </li>
                      
                    </xsl:for-each>
                  </ul>
                </xsl:if>
               
                </li>
              </xsl:for-each>
            </ul>
          </xsl:if>
        </xsl:for-each>
    </xsl:template>

    </xsl:stylesheet>

    Any Suggestions?

  • Mads Sørensen 188 posts 433 karma points
    Jun 06, 2012 @ 15:26
    Mads Sørensen
    0

    Okay i've tryed to simplyfi it a bit, but it still dosen't work :o(


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

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

    <xsl:param name="currentPage"/>


    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">
        <ul>   
          <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
            <li class="menu{@urlName}">
              <xsl:attribute name="class">
                  <xsl:if test="$currentPage/ancestor-or-self::*/@id = @id">naviLv1Activexsl:if>
                xsl:attribute>
              <a>
                <xsl:attribute name="href">
                  <xsl:choose>
                    <xsl:when test="@nodeType=1050"><xsl:value-of select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::Pages/@id)"/>xsl:when>
                    <xsl:otherwise><xsl:value-of select="umbraco.library:NiceUrl(@id)"/>xsl:otherwise>
                  xsl:choose>
                xsl:attribute>
                <xsl:value-of select="@nodeName"/> <xsl:value-of select="@isDoc"/>
              a>
            
            <xsl:if test="count(current()/child::*[@isDoc]) > 0 and $currentPage/@id = current()/@id">
              
                  <ul class="dropDownNavi">
                    
                    <xsl:for-each select="./child::* [@isDoc and string(umbracoNaviHide) != '1']">
              
                    <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">xsl:if>
                    <li>
                        <a>
                          <xsl:attribute name="href">
                            <xsl:choose>
                              <xsl:when test="@nodeType=1050"><xsl:value-of select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::Pages/@id)"/>xsl:when>
                              <xsl:otherwise><xsl:value-of select="umbraco.library:NiceUrl(@id)"/>xsl:otherwise>
                            xsl:choose>
                          xsl:attribute>
                          <xsl:value-of select="@nodeName"/> <xsl:value-of select="@isDoc"/>
                        a>
                    li>
                    xsl:for-each>
                  ul>
                xsl:if>
              
            li>
          xsl:for-each>
        ul>

    xsl:template>
      
        
    xsl:stylesheet>
  • Mads Sørensen 188 posts 433 karma points
    Jun 06, 2012 @ 15:29
    Mads Sørensen
    0

    Argh there it was :o)

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

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

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">
        <ul>   
          <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
            <li class="menu{@urlName}">
              <xsl:attribute name="class">
                  <xsl:if test="$currentPage/ancestor-or-self::*/@id = @id">naviLv1Active</xsl:if>
                </xsl:attribute>
              <a>
                <xsl:attribute name="href">
                  <xsl:choose>
                    <xsl:when test="@nodeType=1050"><xsl:value-of select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::Pages/@id)"/></xsl:when>
                    <xsl:otherwise><xsl:value-of select="umbraco.library:NiceUrl(@id)"/></xsl:otherwise>
                  </xsl:choose>
                </xsl:attribute>
                <xsl:value-of select="@nodeName"/> <xsl:value-of select="@isDoc"/>
              </a>
            
            <xsl:if test="count(current()/child::*[@isDoc]) > 0 ">
              
                  <ul class="dropDownNavi">
                    <!--output 3rd level nevigation items -->
                    <xsl:for-each select="./child::* [@isDoc and string(umbracoNaviHide) != '1']">
              
                    <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id"></xsl:if>
                    <li>
                        <a>
                          <xsl:attribute name="href">
                            <xsl:choose>
                              <xsl:when test="@nodeType=1050"><xsl:value-of select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::Pages/@id)"/></xsl:when>
                              <xsl:otherwise><xsl:value-of select="umbraco.library:NiceUrl(@id)"/></xsl:otherwise>
                            </xsl:choose>
                          </xsl:attribute>
                          <xsl:value-of select="@nodeName"/> <xsl:value-of select="@isDoc"/>
                        </a>
                    </li>
                    </xsl:for-each>
                  </ul>
                </xsl:if>
              
            </li>
          </xsl:for-each>
        </ul>

    </xsl:template>
      
        
    </xsl:stylesheet>
Please Sign in or register to post replies

Write your reply to:

Draft