Copied to clipboard

Flag this post as spam?

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


  • Connie DeCinko 931 posts 1160 karma points
    Aug 02, 2010 @ 20:51
    Connie DeCinko
    0

    Repeat results of select on all child pages

    I have some XSLT that succesfully gets all the child nodes for display as subnavigation.  I want that exact list of child nodes to display in the subnav of all child pages.  The first part of the code below works perfect, gives me the parent node on every page.

    How do I get the second portion to work on child pages?  Is there a way to force it to travel up the tree and always start at the same node, no matter what page and how deep the XSLT is being displayed from?

    <div class="block">
      <xsl:for-each select="$currentPage/ancestor-or-self::* [@template=1165 and string(umbracoNaviHide) != '1']">
        <h3>
          <a href="{umbraco.library:NiceUrl(@id)}">
            <xsl:value-of select="@nodeName"/>
          </a>
        </h3>
      </xsl:for-each>


      <ul class="products">
        <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
          <xsl:variable name="subItems" select="umbraco.library:GetXmlNodeById(@id)/child::*  [@isDoc and string(umbracoNaviHide) != '1']"/>
          <li>
            <xsl:if test="count($subItems)">
              <xsl:attribute name="class">open</xsl:attribute>
            </xsl:if>
            <a href="{umbraco.library:NiceUrl(@id)}">
              <xsl:value-of select="@nodeName"/>
            </a>
            <xsl:if test="count($subItems)">
              <ul>
                <xsl:for-each select="$subItems">
                  <li>
                    <a href="{umbraco.library:NiceUrl(@id)}">
                      <xsl:value-of  select="@nodeName"/>
                    </a>
                  </li>
                </xsl:for-each>
              </ul>
            </xsl:if>
          </li>
        </xsl:for-each>
      </ul>

    </div>
  • Kim Andersen 1447 posts 2196 karma points MVP
    Aug 02, 2010 @ 22:24
    Kim Andersen
    0

    Hi there Connie.

    I think it should be possible if you use the same selector as the one you use in you first snippet.

    Can you try changing your for-each from this:

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

    to this:

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@template=1165 and string(umbracoNaviHide) != '1']/* [@isDoc and string(umbracoNaviHide) != '1']">

    Thi s should get the child nodes from the node you selected in the first step instead of the child nodes from the current page. I haven't tested it though, but you can try giving it a shoot :)

    /Kim A

  • Connie DeCinko 931 posts 1160 karma points
    Aug 02, 2010 @ 23:13
    Connie DeCinko
    0

    Holy cow, that works!  It's that second part that is the important part.  I could not get it to basically begin one level down.  Now, I just need to understand it for the next time.

    Thanks!

     

Please Sign in or register to post replies

Write your reply to:

Draft