Copied to clipboard

Flag this post as spam?

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


  • Nivedita Rawat 6 posts 26 karma points
    Dec 24, 2011 @ 13:11
    Nivedita Rawat
    0

    Creating dropdown submenu of main menu

    Hello Everyone,

    I am not much aware of XSLT so please help me in creating submenu.

    following is the code I am using in my site but I am not able to create dropdown submenu.  

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

     

      z<xsl:template match="/">

        <ul id="nav">

          <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]/child::* [@isDoc and string(showInMainNav) = '1' and (title != '' or navigationTitle != '')]">

            <li>

              <xsl:if test="position() = last()">

                <xsl:attribute name="class">last</xsl:attribute>

              </xsl:if>

              <a href="{umbraco.library:NiceUrl(./@id)}" title="{title}">

                <xsl:choose>

                  <xsl:when test="string(navigationTitle) != ''">

                    <xsl:value-of select="string(navigationTitle)"/>

                  </xsl:when>

                  <xsl:otherwise>

                    <xsl:value-of select="title"/>

                  </xsl:otherwise>

                </xsl:choose>           

              </a>

            </li>

          </xsl:for-each>

        </ul>  

      </xsl:template>

     

      <xsl:template name="RenderMenu">

        <xsl:param name ="root" />

        <xsl:param name ="maximumLevel" />

     

        <xsl:if test="count($root/child::*  [@isDoc and string(hideFromNavigation) != '1']) &gt; 0">

          <ul>

            <xsl:for-each select="$root/child::*  [@isDoc and string(hideFromNavigation) != '1']">

              <li>

                <xsl:if test="$currentPage/ancestor-or-self::* [@isDoc]/@id = ./@id">

                  <xsl:attribute name="class">active</xsl:attribute>

                </xsl:if>

                <a href="{umbraco.library:NiceUrl(./@id)}" title="{title}">

                  <xsl:choose>

                    <xsl:when test="string(navigationTitle) != ''">

                      <xsl:value-of select="navigationTitle"/>

                    </xsl:when>

                    <xsl:otherwise>

                      <xsl:value-of select="title"/>

                    </xsl:otherwise>

                  </xsl:choose>

                </a>

                <xsl:if test="./@level &lt; $maximumLevel and $currentPage/ancestor-or-self::* [@isDoc]/@id = ./@id">

                  <xsl:call-template name="RenderMenu">

                    <xsl:with-param name="root" select="." />

                    <xsl:with-param name="maximumLevel" select="$maximumLevel" />

                  </xsl:call-template>

                </xsl:if>

              </li>

            </xsl:for-each>

          </ul>

        </xsl:if>

      </xsl:template>

    </xsl:stylesheet>

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  • Rich Green 2246 posts 4008 karma points
    Dec 24, 2011 @ 13:16
    Rich Green
    0

    Hi,

    Welcome to the forum!

    It may help if you post the HTML you are trying to produce

    Rich

     

  • Nivedita Rawat 6 posts 26 karma points
    Dec 24, 2011 @ 13:28
    Nivedita Rawat
    0

    Thank u so much..

    I want menu of like this

     

    <html>
    <body>
     <ul>
      <li>Home
      <ul>
       <li>About Us</li>
       <li>Company</li>
      </ul>
       </li>
     <ul>
    </body>
    </html>

  • Rich Green 2246 posts 4008 karma points
    Dec 24, 2011 @ 13:33
    Rich Green
    0

    Hi,

    I would create a new XSLT file and choose the 'Site Map' template, you should be able to tweak this to achieve what you need.

    Let me know how you get on.

    Rich

  • Nivedita Rawat 6 posts 26 karma points
    Dec 24, 2011 @ 13:37
    Nivedita Rawat
    0

    Ok, Please post it on this forum or mail me on [email protected]

  • Rich Green 2246 posts 4008 karma points
    Dec 24, 2011 @ 13:38
    Rich Green
    0

    Hi,

    It's already in the back end, you just login to Umbraco, go to the developers sections press "create" and then choose the template.

    Rich

  • Nivedita Rawat 6 posts 26 karma points
    Dec 24, 2011 @ 13:42
    Nivedita Rawat
    0

    Actualy, i have create menu by Macro using XSLT. So if you help me to make changes in posted XSLT to create submenu. i am realy greatful to you.

     

    Thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 24, 2011 @ 15:37
    Jan Skovgaard
    0

    Hi Nivedita

    What does the code above output?

    Is it creating a list structure like

    <ul>
    <li><a href="#">Item 1</a>
         <ul>
             <li>Subitem 1</li>
         </ul>
    </li>
    </ul>

    Then you should be able to create the dropdown effect simply by using CSS. A simple sample could be something like this...(from the top of my head)

    li{position:relative}
    li ul{position:absolute;top:20px;left:0;display:none}

    li a:hover ul{display:block}

    I hope this is what you're after and that i's enough to get you started :)

    /Jan

  • Nivedita Rawat 6 posts 26 karma points
    Dec 26, 2011 @ 06:06
    Nivedita Rawat
    0

    Hello Everyone..

    Basically I want to do some correction in the above code that i have posted.. because its giving me the menu bt not the submenu..

    so please help me with this..

  • Nivedita Rawat 6 posts 26 karma points
    Dec 26, 2011 @ 07:02
    Nivedita Rawat
    0

    It Should look like this

    Main1        Main2
     |                    |
     SubMenu1     SubMenu3
     |                    |
     SubMenu2      SubMenu4

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 26, 2011 @ 10:46
    Jan Skovgaard
    0

    Hi Nivedita

    As RIch suggested above you should use the sitemap.xslt, which is found in the "create xslt wizard" window where there is a dropdown where it can be chosen. Then you should modify it to match your needs.

    Then you will get all the specified levels. When that is done you should be able to apply the above styling.

    Hope this helps.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft