Copied to clipboard

Flag this post as spam?

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


  • Jordy Vialoux 73 posts 103 karma points
    Aug 01, 2012 @ 23:14
    Jordy Vialoux
    0

    Sub Navigation - XSLT

    Hi Guys,

    I have created a sub nav within xslt and is working fine - here is my code: 

    <xsl:param name="currentPage"/>
    <xsl:variable name="level" select="4"/>
    <xsl:variable name="subLevel" select="5"/>

        
    <xsl:template match="/">
      
      <xsl:if test="$currentPage/showCommunityDevelopmentProgrammes = '1'">
        <div id="list-comm-develop-wrap">  
          <div id="comm-heading-wrap">
            <span>
              <xsl:value-of select="$currentPage/@nodeName" /> Community Development Programmes
            </span>  
          </div>  
          <ul id="list-comm-developments">
            <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
              <li>
                <href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="@nodeName" />
                </a>
              </li>
              </xsl:for-each>
              <li>
                <ul class="comm-sub-nav">
                  <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$subLevel]/* [@isDoc and string(umbracoNaviHide) != '1']" >
                    <li>
                      <href="{umbraco.library:NiceUrl(@id)}">
                        <xsl:value-of select="@nodeName" />
                      </a>
                    </li>
                  </xsl:for-each>
                </ul>
              </li
          </ul>
        </div>
      </xsl:if>

    </xsl:template>

    The only issue is that ".comm-sub-nav" is not pulling through subnodes and I want them to appear underneath the correct parent node if that makes sense? 

    So the parent node is a doc type named "Country" and then underneath you have a doctype named "Community" - within the content section of umbraco you can create another "Community" page underneath a "Community" so what I have is a community within a community.

    I need the 2nd level community to appear underneath the correct coresponding parent community node.

    I hope this is specific enough - any questions I will be watching the thread.

  • Dan 1288 posts 3921 karma points c-trib
    Aug 02, 2012 @ 20:58
    Dan
    1

    Hi Jordy,

    Something like this should get you started:

    <xsl:variable name="startingLevel" select="4"/>

    <xsl:template match="/">
      <ul class="parent-nodes">
        <xsl:apply-templates select="$currentPage/ancestor-or-self::* [@level=$startingLevel]/* [@isDoc and string(umbracoNaviHide) != '1']" />
      </ul>
    </xsl:template>

    <!-- Template for generic document type -->
    <xsl:template match="*[@isDoc]">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName" />
        </a>
        <xsl:if test="*[@isDoc and string(umbracoNaviHide) != '1']">
          <ul class="child-nodes">
            <xsl:apply-templates select="*[@isDoc]" />
          </ul>
        </xsl:if>
      </li>
    </xsl:template>

    <!-- Empty template for hidden nodes -->
    <xsl:template match="*[string(umbracoNaviHide) = '1']" /> 

    You can filter the child nodes to limit them to a particular level or by document type etc.

  • Jordy Vialoux 73 posts 103 karma points
    Aug 02, 2012 @ 23:49
    Jordy Vialoux
    0

    Dan you beauty!!! Thank you so much this works a treat!!! 

Please Sign in or register to post replies

Write your reply to:

Draft