Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Posts
    131
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Dynamic Multi Level Menu

    Hello,

    I have a menu that I'm trying to implement. Can someone help write a XSL that will output the following?

    Code:
    <div id="ddtopmenubar" class="mattblackmenu">
    <ul>
    <li><a href="http://www.dynamicdrive.com">Home</a></li>
    <li><a href="http://www.dynamicdrive.com/new.htm" rel="ddsubmenu1">DHTML</a></li>
    <li><a href="http://www.dynamicdrive.com/style/" rel="ddsubmenu2">CSS</a></li>
    <li><a href="http://www.dynamicdrive.com/forums/">Forums</a></li>
    <li><a href="http://tools.dynamicdrive.com/" rel="ddsubmenu3">Web Tools</a></li>
    </ul>
    </div>
    
    <script type="text/javascript">
    ddlevelsmenu.setup("ddtopmenubar", "topbar") //ddlevelsmenu.setup("mainmenuid", "topbar|sidebar")
    </script>
    Code:
    <!--Drop Down Menu 1 HTML-->
    
    <ul id="ddsubmenu1" class="ddsubmenustyle">
    <li><a href="#">Item 1a</a></li>
    <li><a href="#">Item 2a</a></li>
    <li><a href="#">Item Folder 3a</a>
     <ul>
     <li><a href="#">Sub Item 3.1a</a></li>
     </ul>
    </li>
    <li><a href="#">Item 4a</a></li>
    <li><a href="#">Item Folder 5a</a>
     <ul>
     <li><a href="#">Sub Item 5.1a</a></li>
     <li><a href="#">Item Folder 5.2a</a>
      <ul>
      <li><a href="#">Sub Item 5.2.1a</a></li>
      <li><a href="#">Sub Item 5.2.2a</a></li>
      </ul>
     </li>
     </ul>
    </a>
    </li>
    <li><a href="#">Item 6a</a></li>
    </ul>
    Here's the XML:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <system-index-block name="context-navigation" type="folder" current-time="1235688727060">
       <system-page id="b0a5409e80c8a8b600382de58e642e77">
          <name>index</name>
    
          <title>index</title>
    
          <display-name>index</display-name>
    
          <path>/Level1/Level2/Level3/index</path>
    
          <dynamic-metadata>
             <name>group</name>
    
             <value>Main Page Link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>create-link</name>
    
             <value>create-link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>sort-order</name>
    
             <value>2</value>
          </dynamic-metadata>
       </system-page>
    
       <system-symlink id="b05d9d8580c8a8b600382de5a3231d2f">
          <name>about_page</name>
    
          <title>About UC Irvine</title>
    
          <path>/Level1/Level2/Level3/about_page</path>
    
          <dynamic-metadata>
             <name>group</name>
    
             <value>test</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>create-link</name>
    
             <value>create-link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>sort-order</name>
    
             <value>2</value>
          </dynamic-metadata>
    
          <link>http://www.Level2.page.edu/about_page.html</link>
       </system-symlink>
    
       <system-page id="aa97807080c8a8b601cf08b717f774a8">
          <name>subpage2</name>
    
          <title>Sub Page</title>
    
          <path>/Level1/Level2/Level3/subpage2</path>
    
          <dynamic-metadata>
             <name>group</name>
    
             <value>Sub Page Link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>create-link</name>
    
             <value>create-link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>sort-order</name>
    
             <value>2</value>
          </dynamic-metadata>
       </system-page>
    
       <system-folder id="6c68ad5580c8a8b6001b9c3fdda3dda8">
          <name>css</name>
    
          <path>/Level1/Level2/Level3/css</path>
       </system-folder>
    
       <system-folder id="6c6896b180c8a8b6001b9c3f02457a02">
          <name>_cms</name>
    
          <path>/Level1/Level2/Level3/_cms</path>
    
          <system-folder id="722df3e480c8a8b6001b9c3f0b800764">
             <name>content_blocks</name>
    
             <path>/Level1/Level2/Level3/_cms/content_blocks</path>
          </system-folder>
    
          <system-folder id="725849dd80c8a8b6001b9c3fc25f4584">
             <name>Templates</name>
    
             <path>/Level1/Level2/Level3/_cms/Templates</path>
          </system-folder>
    
          <system-folder id="725a24a880c8a8b6001b9c3f44efdb92">
             <name>XSL</name>
    
             <path>/Level1/Level2/Level3/_cms/XSL</path>
          </system-folder>
       </system-folder>
    
       <system-folder id="6c68395d80c8a8b6001b9c3fe79570f5">
          <name>images</name>
    
          <path>/Level1/Level2/Level3/images</path>
    
          <system-folder id="6c687b0480c8a8b6001b9c3f8f5464e4">
             <name>standard</name>
    
             <path>/Level1/Level2/Level3/images/standard</path>
          </system-folder>
    
          <system-folder id="6c685f6e80c8a8b6001b9c3f34807589">
             <name>dynamic</name>
    
             <path>/Level1/Level2/Level3/images/dynamic</path>
          </system-folder>
    
          <system-folder id="7223a45880c8a8b6001b9c3f7605a6a1">
             <name>circleimg</name>
    
             <path>/Level1/Level2/Level3/images/circleimg</path>
          </system-folder>
       </system-folder>
    
       <system-page id="6c6833bc80c8a8b6001b9c3fe310f944">
          <name>main</name>
    
          <title>Main Page</title>
    
          <path>/Level1/Level2/Level3/main</path>
    
          <dynamic-metadata>
             <name>group</name>
    
             <value>Main Page Link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>create-link</name>
    
             <value>create-link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>sort-order</name>
    
             <value>2</value>
          </dynamic-metadata>
       </system-page>
    
       <system-page id="6c6832e580c8a8b6001b9c3ffdcf42b0">
          <name>subpage</name>
    
          <title>Sub Page</title>
    
          <display-name>Sub Page</display-name>
    
          <path>/Level1/Level2/Level3/subpage</path>
    
          <dynamic-metadata>
             <name>group</name>
    
             <value>Sub Page Link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>create-link</name>
    
             <value>create-link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>sort-order</name>
    
             <value>2</value>
          </dynamic-metadata>
       </system-page>
    
       <system-folder id="6cefd30780c8a8b6001b9c3f30eca36f">
          <name>js</name>
    
          <path>/Level1/Level2/Level3/js</path>
       </system-folder>
    
       <system-folder id="8685bb2480c8a8b601cf08b73c559c1a">
          <name>intl</name>
    
          <title>International</title>
    
          <display-name>International</display-name>
    
          <path>/Level1/Level2/Level3/intl</path>
    
          <dynamic-metadata>
             <name>group</name>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>create-link</name>
    
             <value>create-link</value>
          </dynamic-metadata>
    
          <dynamic-metadata>
             <name>sort-order</name>
    
             <value>5</value>
          </dynamic-metadata>
    
          <system-page id="8698485d80c8a8b601cf08b7bf8a282e">
             <name>index</name>
    
             <title>index</title>
    
             <path>/Level1/Level2/Level3/intl/index</path>
    
             <dynamic-metadata>
                <name>group</name>
    
                <value>Main Page Link</value>
             </dynamic-metadata>
    
             <dynamic-metadata>
                <name>create-link</name>
    
                <value>create-link</value>
             </dynamic-metadata>
    
             <dynamic-metadata>
                <name>sort-order</name>
    
                <value>1</value>
             </dynamic-metadata>
          </system-page>
    
          <system-folder id="86ab7b5080c8a8b601cf08b7b40bcc57">
             <name>test</name>
    
             <title>Test</title>
    
             <path>/Level1/Level2/Level3/intl/test</path>
    
             <dynamic-metadata>
                <name>group</name>
             </dynamic-metadata>
    
             <dynamic-metadata>
                <name>create-link</name>
    
                <value>create-link</value>
             </dynamic-metadata>
    
             <dynamic-metadata>
                <name>sort-order</name>
             </dynamic-metadata>
    
             <system-page id="b4863bb380c8a8b601b993d606bf2824">
                <name>main1</name>
    
                <title>Main Page</title>
    
                <path>/Level1/Level2/Level3/intl/test/main1</path>
    
                <dynamic-metadata>
                   <name>group</name>
    
                   <value>Main Page Link</value>
                </dynamic-metadata>
    
                <dynamic-metadata>
                   <name>create-link</name>
    
                   <value>create-link</value>
                </dynamic-metadata>
    
                <dynamic-metadata>
                   <name>sort-order</name>
    
                   <value>1</value>
                </dynamic-metadata>
             </system-page>
    
             <system-page id="86ac08c280c8a8b601cf08b791d22c31">
                <name>main</name>
    
                <title>Main Page</title>
    
                <path>/Level1/Level2/Level3/intl/test/main</path>
    
                <dynamic-metadata>
                   <name>group</name>
    
                   <value>Main Page Link</value>
                </dynamic-metadata>
    
                <dynamic-metadata>
                   <name>create-link</name>
    
                   <value>create-link</value>
                </dynamic-metadata>
    
                <dynamic-metadata>
                   <name>sort-order</name>
    
                   <value>1</value>
                </dynamic-metadata>
             </system-page>
          </system-folder>
       </system-folder>
    </system-index-block>
    ---------
    Client / Server Side Programmer II

  • #2
    Regular Coder
    Join Date
    Sep 2006
    Posts
    131
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Here's what i have so far. Makes a standard list though.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output indent="yes" method="xml"/>
    
       <xsl:template match="system-index-block">
          <ul class="treeview" id="treemenu1">
             <xsl:apply-templates select="system-page | system-folder[system-page] | system-symlink ">
                <xsl:sort data-type="number" select="dynamic-metadata[name='sort-order']/value"/>
             </xsl:apply-templates>
          </ul>
       </xsl:template>
    
       <xsl:template match="system-page">
          <xsl:if test="dynamic-metadata/name='create-link'">
             <li>
                <a>
                   <xsl:attribute name="href">
                      <xsl:value-of select="path"/>
                   </xsl:attribute>
    
                   <xsl:call-template name="get-name"/>
                </a>
             </li>
          </xsl:if>
       </xsl:template>
    
       <xsl:template match="system-folder">
          <xsl:if test="dynamic-metadata/name='create-link'">
             <li>
                <a>
                   <xsl:attribute name="href">
                      <xsl:value-of select="system-page[name = 'index']/path"/>
                   </xsl:attribute>
    
                   <xsl:call-template name="get-name"/>
                </a>
    
                <ul>
                   <xsl:apply-templates select="system-page[name != 'index'] | system-folder[system-page]"/>
                </ul>
             </li>
          </xsl:if>
       </xsl:template>
    
       <xsl:template match="system-symlink">
          <xsl:if test="dynamic-metadata/name='create-link'">
             <li>
                <a>
                   <xsl:attribute name="href">
                      <xsl:value-of select="path"/>
                   </xsl:attribute>
    
                   <xsl:call-template name="get-name"/>
                </a>
             </li>
          </xsl:if>
       </xsl:template>
    
       <xsl:template name="get-name">
          <xsl:choose>
             <xsl:when test="display-name">
                <xsl:value-of select="display-name"/>
             </xsl:when>
    
             <xsl:when test="title">
                <xsl:value-of select="title"/>
             </xsl:when>
    
             <xsl:otherwise>
                <xsl:value-of select="name"/>
             </xsl:otherwise>
          </xsl:choose>
       </xsl:template>
    </xsl:stylesheet>
    ---------
    Client / Server Side Programmer II


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •