Copied to clipboard

Flag this post as spam?

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


  • Søren Klemensen 16 posts 36 karma points
    Jul 26, 2011 @ 13:53
    Søren Klemensen
    0

    dropdown menu in Xslt

    Hi all

    I new at umbraco and have taken over a website build in umbraco. Therefor i hope for some help.

    Im interesting at makeing a dropdown menu on the website and im being told to integrate it at my nav xslt. But i tried sevaral times but im getting som errors.

    my current nav xslt is build on some macros, and i want to keep im, but add some more topic in the menu. Is it possible and how?

    im here posting my Xslt;

    <?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"/>
    <xsl:variable name="level" select="1"/>
    <xsl:template match="/">
    <!-- start writing XSLT -->
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
     <xsl:choose>
      <xsl:when test="@nodeType != '1492'"> 
       <li class="mega"><a href="{umbraco.library:NiceUrl(@id)}" class="topNavi"><font class="head"><xsl:value-of select="@nodeName"/></font><br/><font class="sub"><xsl:value-of select="data [@alias='underheadline']" disable-output-escaping="yes"/></font></a></li>
      </xsl:when>
      <xsl:otherwise>
       <xsl:variable name="link" select="data [@alias='linktotournament']" />
       <li class="mega"><a href="{$link}" target="_blank" class="topNavi"><font class="head"><xsl:value-of select="@nodeName"/></font><br/><font class="sub"><xsl:value-of select="data [@alias='underheadline']" disable-output-escaping="yes"/></font></a></li>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

     

    I hope someone cal helt or give me some tips. if you want to see the page, its on www.dype.dk

    I have looked at Superfish, but failed to integrete it.

  • Søren Klemensen 16 posts 36 karma points
    Jul 26, 2011 @ 14:06
    Søren Klemensen
    0

    Sry about the spelling getting and error in my edt.

    Hi all

    I am new at umbraco and have taken over a website build in umbraco. Therefor i hope for some help.

    Im interesting at makeing a dropdown menu on the website and im being told to integrate it at my nav xslt. But i tried sevaral times and im getting som errors.

    my current nav xslt is build on some macros, and i want to keep im, but add some more topic in the menu. Is it possible and how?

    im here posting my Xslt;

     

    CODE

     

     

    I hope someone can help or give me some tips. if you want to see the page, its on www.dype.dk

    I have looked at Superfish, but failed to integrete it.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 26, 2011 @ 16:15
    Fuji Kusaka
    0

    Hi Soren,

     

    Is the website www.dype.dk the one you are working on?..are do you intend to implement in the navigation?

     

    //fuji

  • Søren Klemensen 16 posts 36 karma points
    Jul 26, 2011 @ 16:27
    Søren Klemensen
    0

    Hi Fuji.

    Yes its www.dype.dk im working on, and as i understand you have to make the menu in the xslt as there is already made some macro's due to the current side menu structure.

    If i make it in the template it wont be dynamic. Therefore i hope that someone can help me solve how to.  I just one simple, e.g. Superfish basic. The site have already a dropdown in statestik, but its different as its collecting some data.

    My reason for dropdown is that i want more topics and it will save space.

    - Soren

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 26, 2011 @ 17:32
    Fuji Kusaka
    0

    Soren, it all depends what you are looking  for. If you want a dynamic menu with drop down menu i would go for XSLT and use it in a template. Now from what i understand you just want a simple menu with drop downs ??

    You can try by creating a XSLT by  Level and try this..

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

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
     
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
       <li>         
        <a href="umbraco.library:NiceUrl(@id)">
         <xsl:value-of select="@nodeName"/>
       </a>
        
        <!-- Drop Down Menu -->
        
        <xsl:if test="count(./*[@isDoc and string(umbracoNaviHide) !='1'])&gt;0">
          <ul>
            <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) !='1']">
               <li>
                <a href="umbraco.library:NiceUrl(@id)">             
                  <xsl:value-of select="@nodeName"/></a>
              </li>
            </xsl:for-each>
          </ul>
        </xsl:if>

        <!-- End Of Drop Down Menu -->
      </li>
    </xsl:for-each>
    </ul>
  • Søren Klemensen 16 posts 36 karma points
    Jul 26, 2011 @ 18:39
    Søren Klemensen
    0

    I have no tried it, but its like my menu is being vertical. Is it because i havde to change the content? i just want i like :http://users.tpg.com.au/j_birch/plugins/superfish/#examples

     

    If i write it in the current Nav XSLT to one complete it looks like this right?

    <?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"/>
    <xsl:variable name="level" select="1"/>
    <xsl:template match="/">

    <!-- The fun starts here -->
     <ul>  
     <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
     <li>            
     <a href="umbraco.library:NiceUrl(@id)">
     <xsl:value-of select="@nodeName"/>
     </a>
             <!-- Drop Down Menu -->
             <xsl:if test="count(./*[@isDoc and string(umbracoNaviHide) !='1'])&gt;0">
     <ul>       
     <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) !='1']">          
     <li>           
     <a href="umbraco.library:NiceUrl(@id)">                           
     <xsl:value-of select="@nodeName"/></a>
             </li>
             </xsl:for-each>
           </ul>   
     </xsl:if>   
     <!-- End Of Drop Down Menu --> 
     </li> 
     </xsl:for-each>
     </ul>

    <!-- start writing XSLT -->
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
     <xsl:choose>
      <xsl:when test="@nodeType != '1492'"> 
       <li class="mega"><a href="{umbraco.library:NiceUrl(@id)}" class="topNavi"><font class="head"><xsl:value-of select="@nodeName"/></font><br/><font class="sub"><xsl:value-of select="data [@alias='underheadline']" disable-output-escaping="yes"/></font></a></li>
      </xsl:when>
      <xsl:otherwise>
       <xsl:variable name="link" select="data [@alias='linktotournament']" />
       <li class="mega"><a href="{$link}" target="_blank" class="topNavi"><font class="head"><xsl:value-of select="@nodeName"/></font><br/><font class="sub"><xsl:value-of select="data [@alias='underheadline']" disable-output-escaping="yes"/></font></a></li>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 26, 2011 @ 18:44
    Fuji Kusaka
    0

    Soren, give this a try then all you will need to make the drop down to show is some css. Or you can also have a look at this post http://our.umbraco.org/forum/developers/xslt/22375-Xslt-and-Superfish-menu

  • Søren Klemensen 16 posts 36 karma points
    Jul 27, 2011 @ 10:35
    Søren Klemensen
    0

    Hi again

    i also tried the one you linked to, but then nothing happends. i wrote it in the nav.xslt , in my master template. But i can still not create any in my content tree.

    I would like to look like this:

    I cant see where im wrong.. There must be something im missing

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 27, 2011 @ 11:19
    Fuji Kusaka
    0

    Hi Soren, can you show us your XSLT and how your Content Structure Looks like?

  • Søren Klemensen 16 posts 36 karma points
    Jul 27, 2011 @ 11:59
    Søren Klemensen
    0

     

    <?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"/>
    <xsl:variable name="level" select="1"/>
    <xsl:template match="/">
    <!-- start writing XSLT -->
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <xsl:choose>
      <xsl:when test="@level = 2">
     <xsl:value-of select="@nodeName" />
     </xsl:when>
     <xsl:otherwise>
     <a href="{umbraco.library:NiceUrl(@id)}">
       <xsl:value-of select="@nodeName"/>
      </a>
    </xsl:otherwise>
    </xsl:choose>
     
      <xsl:choose>
      <xsl:when test="@nodeType != '1492'"> 
       <li class="mega"><a href="{umbraco.library:NiceUrl(@id)}" class="topNavi"><font class="head"><xsl:value-of select="@nodeName"/></font><br/><font class="sub"><xsl:value-of select="data [@alias='underheadline']" disable-output-escaping="yes"/></font></a></li>
      </xsl:when>
      <xsl:otherwise>
       <xsl:variable name="link" select="data [@alias='linktotournament']" />
       <li class="mega"><a href="{$link}" target="_blank" class="topNavi"><font class="head"><xsl:value-of select="@nodeName"/></font><br/><font class="sub"><xsl:value-of select="data [@alias='underheadline']" disable-output-escaping="yes"/></font></a></li>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
  • Kasper Dyrvig 246 posts 379 karma points
    Jul 27, 2011 @ 12:36
    Kasper Dyrvig
    0

    Hi Søren,

    Sorry to "drop in" in the middle of your discussion, but I have a suggestion for a solution :-)

    I can see your Umbraco installation isn't all new, it uses the old XSLT schema.

    I have made a lot of dropdown menus in XSLT. Try make a new XSLT file, select Sitemap as the template. That'll create the basic XSLT you need: a list with all the pages.

    <div id="divMainMenu">
    <ul class="mainMenu">
    <li>Spillere
    <ul>
    <li>Spillerprofiler</li>
    <li>Skadeliste</li>
    <li>Bøderegler</li>
    <li>Transfers</li>
    </ul>
    </li>
    <li>Forum
    <ul>
    <li>Chat</li>
    </ul>
    </li>
    <li>Tilmelding</li>
    </ul>
    </div>

    You can use XSLT to check witch page is currently viewed.

    From here it's mostly CSS you need to do. Here you have an example:

    #divMainMenu{height: 30px; width: 940px; margin: 0px auto 0px auto; position: relative;}
    #divMainMenu ul#mainMenu{list-style-type: none; padding: 0px; margin: 0px; z-index: 1000; position: absolute; bottom: 0px;}
    #divMainMenu ul#mainMenuli{float: left; margin-right: 5px; position: relative;}
    #divMainMenu ul#mainMenuli a{display: block; height: 30px; text-decoration: none; line-height: 30px;}
    #divMainMenu ul#mainMenuli a:hover, #divMainMenu ul#menuItems li:hover a{background-color: #cccccc;}
    #divMainMenu ul#mainMenuli a#currentItem{color: #ffffff; background-color: #000000;}
    #divMainMenu ul#mainMenuli ul{display: none; background-color: #cccccc; position: absolute; top: 30px; left: 0px; width: 200px; list-style-type: none; padding: 0px; margin: 0px;}
    #divMainMenu ul#mainMenuli:hover ul{display: block;}
    #divMainMenu ul#mainMenuli ul li{float: none; height: 30px; padding: 0px; margin: 0px;}
    #divMainMenu ul#mainMenuli ul li a{padding: 0px 15px 0px 15px; margin: 0px; line-height: 30px;}
    #divMainMenu ul#mainMenuli ul li:hover, #divMainMenu ul#menuItems li ul li a:hover{background-color: #eeeeee;}

    Now - according to your link - all you have to do is calling the script and connect it to the <ul id="mainMenu">.

  • Kasper Dyrvig 246 posts 379 karma points
    Jul 27, 2011 @ 12:40
    Kasper Dyrvig
    0

    Arh... sorry, the html sample should contain <ul id="mainMenu"> not <ul class="mainMenu">

    And it seems like Our has deleted some spaces in the css sample...

  • Søren Klemensen 16 posts 36 karma points
    Jul 27, 2011 @ 13:18
    Søren Klemensen
    0

    Hi Kasper

    Thanx for your input. I create a new XSLT and select sitemap i get following error

    both with id or class

    Error occured

    System.Xml.XmlException: 'at System.Xml.XmlTextReaderImpl.Throw(Exception e)
    at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
    at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2)
    at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(Int32 pos, String expectedToken1, String expectedToken2)
    at System.Xml.XmlTextReaderImpl.ParseEndElement()
    at System.Xml.XmlTextReaderImpl.ParseElementContent()
    at System.Xml.XmlTextReaderImpl.Read()
    at System.Xml.Xsl.Xslt.XsltInput.ReadNextSiblingHelper()
    at System.Xml.Xsl.Xslt.XsltInput.ReadNextSibling()
    at System.Xml.Xsl.Xslt.XsltInput.MoveToNextSibling()
    at System.Xml.Xsl.Xslt.XsltLoader.LoadInstructions(List`1 content, InstructionFlags flags)
    at System.Xml.Xsl.Xslt.XsltLoader.LoadLiteralResultElement(Boolean asStylesheet)
    at System.Xml.Xsl.Xslt.XsltLoader.LoadInstructions(List`1 content, InstructionFlags flags)
    at System.Xml.Xsl.Xslt.XsltLoader.LoadTemplate(NsDecl stylesheetNsList)
    at System.Xml.Xsl.Xslt.XsltLoader.LoadRealStylesheet()
    at System.Xml.Xsl.Xslt.XsltLoader.LoadDocument()
    at System.Xml.Xsl.Xslt.XsltLoader.LoadStylesheet(XmlReader reader, Boolean include)

     

    I have include your text and my xslt looks like this:

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


      • Spillere
          • Spillerprofiler

          • Skadeliste

          • Bøderegler

          • Transfers



      • Forum
          • Chat



      • Tilmelding





     

      •  

         
          
           
           
         

     




  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 27, 2011 @ 19:02
    Fuji Kusaka
    0

    /Hey Soren, have you been able to get the navigation working?if not ill try to help you again. And btw what version of umbraco are you on?

  • Søren Klemensen 16 posts 36 karma points
    Jul 27, 2011 @ 23:20
    Søren Klemensen
    0

    I finally got something that worked:

    - you can see the temperary work on www.dype.dk. Thanx for your help!!

    <?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"/>
    <xsl:variable name="level" select="1"/>
    <xsl:template match="/">
    <!-- start writing XSLT -->
    <li class="mega">
     <a href="#" class="megaTop"><font class="head">Spillere</font><br/><font class="sub">Få mere info her...</font></a>
     <div class="megaDrop">
      <a href="#">Spillerprofiler</a><br/>
      <a href="#">Skadesliste</a><br/>
      <a href="#">Bøderegler</a><br/>
      <a href="#">Transfer</a><br/>
     </div>
     
    </li>
    <li class="mega">
     <a href="#" class="megaTop"><font class="head">Endnu et</font><br/><font class="sub">... go en underoverskrift</font></a>
    </li>
    <!--
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
     <xsl:choose>
      <xsl:when test="@nodeType != '1492'"> 
       <li class="mega"><a href="{umbraco.library:NiceUrl(@id)}" class="topNavi"><font class="head"><xsl:value-of select="@nodeName"/></font><br/><font class="sub"><xsl:value-of select="data [@alias='underheadline']" disable-output-escaping="yes"/></font></a></li>
      </xsl:when>
      <xsl:otherwise>
       <xsl:variable name="link" select="data [@alias='linktotournament']" />
       <li class="mega"><a href="{$link}" target="_blank" class="topNavi"><font class="head"><xsl:value-of select="@nodeName"/></font><br/><font class="sub"><xsl:value-of select="data [@alias='underheadline']" disable-output-escaping="yes"/></font></a></li>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:for-each>-->
    </xsl:template>

    </xsl:stylesheet>

Please Sign in or register to post replies

Write your reply to:

Draft