Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 661 karma points
    Feb 28, 2012 @ 11:51
    Martin
    0

    Can't seem to list child nodes by ID

    Hi, Im having some issues with listing sub pages of a specific node. 

    I seem to be getting the sub pages repeated under the all nodes.

    Any help woul be grateful.

        <ul class="nav">
          <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 -->
            <href="{umbraco.library:NiceUrl($homeNode/@id)}">
              <xsl:value-of select="$homeNode/@nodeName" />
            </a>
          </li>  
          
        <xsl:for-each select="$homeNode/*[@level = 2][umbracoNaviHide != 1]">         
        <li>
        <!-- APPLY CLASS AND NUMBER -->  
        <xsl:attribute name="class">
           <xsl:text>menuitem</xsl:text><xsl:value-of select="position()" />
        </xsl:attribute>
        <!-- APPLY CLASS AND NUMBER AN CONCAT WITH SELECTED -->       
        <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
          <xsl:attribute name="class">menuitem<xsl:value-of select="concat(position(), ' selected')"/></xsl:attribute>
        </xsl:if>
        <xsl:if test="umbraco.library:HasAccess(@id,@path)">
        <!-- Create the link -->
        <href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a>
        </xsl:if>
          
         <!-- SUBNAV DROP DOWN -->
          <ul class="subnav">
            <xsl:for-each select="umbraco.library:GetXmlNodeById(1055)/Services">
              <li>
                <href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="@nodeName"/>
                </a>
              </li>
            </xsl:for-each>       
          </ul>
          
        </li>
      </xsl:for-each>
      </ul>
  • Seth Niemuth 275 posts 397 karma points
    Feb 28, 2012 @ 12:20
    Seth Niemuth
    0

    I am not sure what you mean exactly but for your outer for each statement (<xsl:for-each select="$homeNode/*[@level = 2][umbracoNaviHide != 1]">) you are going to get all the nodes which are 2 levels below the home node and so if that is always the same then it will always show the same.

    For your subnav dropdown for each statement (<xsl:for-each select="umbraco.library:GetXmlNodeById(1055)/Services">), you are always going to get all the 'Services' children of the node with an ID of 1055. Is that what you mean?

  • Martin 278 posts 661 karma points
    Feb 28, 2012 @ 12:45
    Martin
    0

    Hi Seth.

    Im wanting to show only the child nodes of the Services node (1055).

    I have other nodes on the same level as the Services node, they also have children. I dont want to show any child nodes of level 2.

    It seems that any child of level 2 is being replaced with the Services child nodes. 

    Thanks

     

  • Rob Watkins 343 posts 593 karma points
    Feb 28, 2012 @ 17:56
    Rob Watkins
    0
    $homeNode/*[@level = 2][umbracoNaviHide != 1]

    This doesn't make any sense; as / is an immediate child selector, it looks like this query should either return *all* child nodes of $homeNode, if $homeNode is at level 1; or *no* child nodes at all if $homeNode is at any other level. 

    As Seth says there doesn't appear to be any condition on your Services menu so it will be displayed every time; I'm still not 100% clear on what you want I'm afraid.

    This following code will give you a framework that goes through all children of the home page then displays the services sub-menu only when it hits your services node, if that is the sort of thing you are after?

    <xsl:for-each select="$homeNode/*[@isDoc][umbracoNaviHide != 1]"> 
    <xsl:if test="@id = 1055">
    <xsl:for-each select="Services">
    </xsl:for-each>
    </xsl:if>
    </xsl:for-each>
  • Rob Watkins 343 posts 593 karma points
    Feb 28, 2012 @ 18:08
    Rob Watkins
    1

    Oh my GOD, is it just me that the post editor in this forum is trying to drive insane?!

  • Martin 278 posts 661 karma points
    Feb 28, 2012 @ 22:14
    Martin
    0

    Hi Rob, 

    Thanks that worked

    I was trying to display only the Service children at level 3 of my navigation.

  • 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