Copied to clipboard

Flag this post as spam?

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


  • Maarten Boer 61 posts 82 karma points
    Nov 01, 2010 @ 17:31
    Maarten Boer
    0

    sub menu not showing

    Have a Master Page, Textpage and a Subtext Page.  The textpages should show in my menu.
    The Subtext pages should show as sub menu items.

    Have some trouble show sub-menu.
    Using the following 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"
      exclude-result-prefixes="msxml umbraco.library">


        <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]/* [string(umbracoNaviHide) != '1' and @isDoc]">
              <xsl:choose>
             <xsl:when test="@nodeName= 'Nieuws'">
                        </xsl:when>
                        <xsl:otherwise>
                        <li>
                             <a href="{umbraco.library:NiceUrl(@id)}">
                             <xsl:value-of select="@nodeName"/>
                             </a>
                     <xsl:if test="($currentPage/@id=current()/@id and count(current()/node) > 0) or ($currentPage/@parentID = ./@id)">
         <ul>
             <xsl:for-each select="current()/node">
                   <li>
                 <a href="{umbraco.library:NiceUrl(@id)}">
            <xsl:value-of select="@nodeName"/></a>
        </li>
             </xsl:for-each>
         </ul>
             </xsl:if>
                        </li>
                        </xsl:otherwise>
            </xsl:choose>
                </xsl:for-each>
        </xsl:template>
    </xsl:stylesheet>

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 01, 2010 @ 17:46
    Tom Fulton
    0

    Are you using 4.5.x?  It looks like you are mixing the pre 4.5 and 4.5 schemas.

    If using 4.5, try changing these lines:

    <xsl:if test="($currentPage/@id=current()/@id and count(current()/node) > 0) or ($currentPage/@parentID = ./@id)">
         <ul>
             <xsl:for-each select="current()/node">

    to:

    <xsl:if test="($currentPage/@id=current()/@id and count(current()/* [@isDoc]) > 0) or ($currentPage/@parentID = ./@id)">
         <ul>
             <xsl:for-each select="current()/* [@isDoc]">

    There might be other issues but that's the first thing I'd check :)

  • Maarten Boer 61 posts 82 karma points
    Nov 01, 2010 @ 20:02
    Maarten Boer
    0

    Thanks for the quick response....
    First of all you are right about 4.5. I recently upgraded tot 4.5.

    So i tried the following according your adjustments:

    <?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"
      exclude-result-prefixes="msxml umbraco.library">
        <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]/* [string(umbracoNaviHide) != '1' and @isDoc]">
          <xsl:choose>
            <xsl:when test="@nodeName= 'Nieuws'">
            </xsl:when>
            <xsl:otherwise>
             <li>
                <a href="{umbraco.library:NiceUrl(@id)}">
                 <xsl:value-of select="@nodeName"/>
                </a>
             <xsl:if test="($currentPage/@id=current()/@id and count(current()/* [@isDoc]) > 0) or ($currentPage/@parentID = ./@id)">
         <ul>
             <xsl:for-each select="current()/* [@isDoc]">
                    <li>
                 <a href="{umbraco.library:NiceUrl(@id)}">
            <xsl:value-of select="@nodeName"/></a>
         </li>
             </xsl:for-each>
         </ul>
             </xsl:if>
              </li>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:for-each>
      </xsl:template>
     </xsl:stylesheet>

    Still not showing the submenu's.
    A bit more info....
    My template structure:

    Master Page
             - Home Page
             - Text Page
                      - Sub Text Page

    So all the Textpages form the 1e level of my menu. All the Text Page sub nodes (Sub Text Page) form the 2e level of my menu....al least that's what i want

    Maarten

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 01, 2010 @ 20:24
    Tom Fulton
    0

    According to the code, the subpages will only show when you are on a main-level page that contains subpages, or when you are on one of the subpages.  Is that what you want?

    Also was this working before you upgraded or is this something new you are adding?

    Also the template structure doesn't really matter, it's more about the structure of your Content

  • Maarten Boer 61 posts 82 karma points
    Nov 01, 2010 @ 21:04
    Maarten Boer
    0

    Ok, first of all i haven't tested this of a prev. version of 4.5. This is accually the first time i'm working with sub level menu's
    After republishing all pages it works..... but just as you say it should work.

    The mainpage (home) only shows the 1e level menu items.  After clicking on one of the menu items only then the sub-menu items are loaded and the menu collapses. (you have to click twice...)

    I'd like menu and sub-menus to be loaded at once on the home page...the sub-menus are hidden (css and script)

    Acctually i only want to use the sub-menus as anchors for the current page.

    So this looks something like this

    Homepage
    [menu]
      - products
      - links
      - contacts

    Each page has several paragraphs (anchors)

      - products
          - product 1  (paragraph)
          - product 2  (paragraph)
          - etc.

    By clicking on 'products' it should present the product page with product 1, 2 etc
    So i dont know if making nodes of the sub menu items is the best way....

    All open for suggestions.. 

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 01, 2010 @ 21:43
    Tom Fulton
    0

    I'm a bit confused, but here's some info that might get you started.

    To always write out the submenus, regardless if you are on that page/section or not, change the logic in your second for-each loop.  Right now it has conditions to see if you on a node that has subpages or if you are on one of the subpages.  So just change it to check the count and remove the other conditions:

      <xsl:if test="count(current()/* [@isDoc]) > 0)">

    To link to anchors instead of to the pages, first you have to decide what to use for the anchor text...probably the node ID.  So instead of calling NiceUrl for the ID, just write it out with a # sign...

     <a href="#{@id}">

     

  • Maarten Boer 61 posts 82 karma points
    Nov 03, 2010 @ 21:26
    Maarten Boer
    0

    Hi Tom,

    Sorry for my late response....evering works fine now. Your directions were a great help.

Please Sign in or register to post replies

Write your reply to:

Draft