Copied to clipboard

Flag this post as spam?

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


  • Tom 2 posts 22 karma points
    Feb 27, 2013 @ 23:33
    Tom
    0

    TopNavigation Multi-Layer

    Hi I'm a new umbraco developer, just getting to grips with it. I have created an xslt file to navigate 1 level.

    I need to create an xslt to navigate from a top level navigation like this:

    page 1 >

    sub page 1 >

    sub page 2 >

    sub sub page 1 >

    sub page 3 >

    page 2 >

    I could also use some advice on how to render it.

    thanks for any help you can offer.

     

    here is the XSLT i already have.

     

       <!-- Root Node -->

        <xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::root" />

     

        <!-- Homepage -->

        <xsl:variable name="homeNode" select="$rootNode/Home [@isDoc]" />

     

        <ul id="navi">

          <li>

            <!--

            Add the CSS class 'selected' if the homeNode ID matches our

            currentPage node ID

            -->

            <xsl:if test="$homeNode/@id = $currentPage/@id">

              <xsl:attribute name="class">

                <xsl:text>selected</xsl:text>

              </xsl:attribute>

            </xsl:if>

     

            <!--Create a link to the homepage -->

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

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

            </a>

          </li>

     

          <!--

          For each child node of the homeNode that is a document (isDoc)

          and the level is 2

          and the property umbracoNaviHide is NOT 1 (true/checked)

          -->

          <xsl:for-each select="$homeNode/* [@isDoc and @level = 2 and string(umbracoNaviHide) != '1']">

            <li>

              <!--

              Add the CSS class 'selected' if the currentPage or parent nodes (up the tree to the root)

              ID matches our current node's ID in the for each loop

              -->

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

                <xsl:attribute name="class">

                  <xsl:text>selected</xsl:text>

                </xsl:attribute>

              </xsl:if>

     

              <!-- Create the link -->

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

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

              </a>

            </li>

          </xsl:for-each>

        </ul>

      </xsl:template>

    </xsl:stylesheet>

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 28, 2013 @ 18:27
    Alex Skrypnyk
    0

    What exactly don't work ?

  • Tom 2 posts 22 karma points
    Feb 28, 2013 @ 20:07
    Tom
    0

    the xslt macro only lets me navigate the top layer of my content tree, im not sure how to get it to navigate lower levels of the content tree.

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 28, 2013 @ 21:14
    Alex Skrypnyk
    0

    You should insert nested foreach in the main for-each.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies