Copied to clipboard

Flag this post as spam?

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


  • Evelyne Schreiner 25 posts 74 karma points
    Apr 22, 2012 @ 10:07
    Evelyne Schreiner
    0

    2nd level menu : filtering document types problem

    New to Umbraco and xslt, I’ve got a problem with the menu of my first Umbraco website.

    When displaying a parent page (node), the 2nd level menu is working fine and displaying its children. However, when displaying one of its children pages, the 2nd level menu is not displaying the page and the others with same parent.

    There are some document types I don’t want to display in the menu and it looks like my problem is due to my poor attempt to filter the document types (displaying only “umbTextpage” and “PageTwoColumns”) :

    <xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>

        <xsl:if test="$currentPage/umbTextpage or $currentPage/PageTwoColumns">

          <xsl:if test="count($items) &gt; 0">

            <ul id="subNavigation">

              <xsl:for-each select="$items">

                <li>

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

                    <xsl:value-of select="@nodeName"/>

                  </a>

                </li>

              </xsl:for-each>

            </ul>

          </xsl:if> 

        </xsl:if>

    Any help, please ?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Apr 22, 2012 @ 21:57
    Chriztian Steinmeier
    0

    Hi Evelyne,

    Try this approach:

    <!-- Find the top node for the subnav -->
    <xsl:variable name="currentSection" select="ancestor-or-self::*[@level = 2]" />
    
    <!-- Select the items you want to show off of currentSection -->
    <xsl:variable name="items" select="$currentSection/*[self::umbTextpage or self::PageTwoColumns][not(umbracoNaviHide = 1)]" />
    
    <!-- If that set has any nodes ... -->
    <xsl:if test="$items">
        <ul id="subNavigation">
            <xsl:for-each select="$items">
                <li>
                    <a class="navigation" href="{umbraco.library:NiceUrl(@id)}">
                        <xsl:value-of select="@nodeName" />
                    </a>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:if>

    Using a couple extra variables can make it much easier to read and understand where to put changes etc.

    /Chriztian

  • Evelyne Schreiner 25 posts 74 karma points
    Apr 23, 2012 @ 15:12
    Evelyne Schreiner
    0

    Hi Chriztian,

    Thank you for your reply.

    Unfortunately, it doesn't work. Even in parent page, this xslt don't return any result...

    Thank you,

    Evelyne

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Apr 23, 2012 @ 15:57
    Chriztian Steinmeier
    0

    Hi Evelyne,

    Sorry about that - I forgot to base everything off $currentPage - if you add in the very first line, you should see some results, e.g.:

    <!-- Find the top node for the subnav -->
    <xsl:variable name="currentSection" select="$currentPage/ancestor-or-self::*[@level = 2]" />
    

    /Chriztian

  • Evelyne Schreiner 25 posts 74 karma points
    Apr 25, 2012 @ 11:51
    Evelyne Schreiner
    0

    Yes, it's working !

    Thank you very much, Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft