Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 21:34
    Fuji Kusaka
    0

    Drawing All Nodes of a specific Parent

    Hi All,

    Am so confused and lost in my XSLT atm. Am Trying to display all the nodes present under  a specific Folder with the following id(1168) but am only getting the Sub Nodes of a Child and not even the parent. Anyway what am trying to do is to be able to view all the nodes of a specific folder.

    Content

        Default

        Folder 1

            Link 1

            Link 2

                 Sub Link 1

                Sub Link 2

             Link 3

  • Tommy Poulsen 514 posts 708 karma points
    Jun 09, 2011 @ 22:02
    Tommy Poulsen
    0

    Hi Fuji, you could do something like this to get the children of node 1168:

          <xsl:for-each select="umbraco.library:GetXmlNodeById(1168)/* [@isDoc][string(umbracoNaviHide) != '1']">
              <href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
          </xsl:for-each>

     

    The * can also be substituted with specific node-type-names or xpath specifiers (like descendent::* ...)

    >Tommy

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 22:06
    Fuji Kusaka
    0

    Hi Tommy am using this piece of code at the moment..

     

     

    <xsl:variable name="source" select="1168"/>
    <xsl:variable name="maxLevel" select="4"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
        <xsl:call-template name="drawNodes">  
            <xsl:with-param name="parent" select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']"/>  
        </xsl:call-template>
    </ul>
    </xsl:template>

    <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
    <!--ul-->
    <xsl:if test="$parent/@level &lt; $maxLevel">
     
    <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1']">
        <li>  
         
            <a href="{umbraco.library:NiceUrl(@id)}">
              <xsl:value-of select="@nodeName"/>
            </a>  
         
          <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1']) &gt; 0 and $currentPage/ancestor-or-self::*/@id = current()/@id">  
            <xsl:call-template name="drawNodes">    
                <xsl:with-param name="parent" select="."/>    
            </xsl:call-template>  
          </xsl:if>
         
        </li>
    </xsl:for-each>
     
    </xsl:if>

     

    But only getting the Sub Node of the Child that is in my cas Sub Link 1 and Sub Link 2

     

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 22:10
    Fuji Kusaka
    0

    Btw id (1168) is for the Folder 1 node..

     

    Fuji

  • Tommy Poulsen 514 posts 708 karma points
    Jun 09, 2011 @ 22:11
    Tommy Poulsen
    1

    You go 1 step too deep in your template call/for-each (in your for-each the parent is actually one of your $source children)

    So e.g. replace

    <xsl:with-param name="parent" select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']"/>  
        </xsl:call-template>

    with

    <xsl:with-param name="parent" select="umbraco.library:GetXmlNodeById($source) [@isDoc and string(umbracoNaviHide) != '1']"/>  
        </xsl:call-template>

     

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 09, 2011 @ 22:27
    Dennis Aaen
    1

    Hi Fuji

    I was just doing a little local example. Where I've the following XSLT code to get all nodes out, based on a specific node.
    So maybe you could try something like this

    <xsl:template match="/">


    <ul>
      <xsl:for-each select="umbraco.library:GetXmlNodeById($source)//* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    And the two slash characters represent the descendant axis. So it will get all childs and thir childs, and so on.

    Hope it can helps you.

    /Dennis

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 09, 2011 @ 23:02
    Dennis Aaen
    1

    An apologies to Tommy because I hadn't seen that you had proposed the same example, as I did. And you had added that the * could be replaced by decendants::*

    I´m sorry

    /Dennis

  • Tommy Poulsen 514 posts 708 karma points
    Jun 10, 2011 @ 06:35
    Tommy Poulsen
    0

    Dennis no worries - you supplying an answer, trying to help out on the forum is important. Hopefully one of the posts will solve the problem.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 10, 2011 @ 14:42
    Fuji Kusaka
    0

    Thanks Dennis its working...can you tell me how i can get the subPages to get a class so that the links indent?

     <xsl:attribute name="class">
             <xsl:choose>          
               <xsl:when test="$currentPage/@id and @level=2]">
                     <xsl:text>left-menu-slink</xsl:text>        
                </xsl:when>
               
                   <xsl:otherwise>
                    <xsl:text></xsl:text>
                   </xsl:otherwise>                 
                 </xsl:choose>               
              <xsl:if test="$currentPage/@id = current()/@id">
                   <xsl:text> current</xsl:text>
              </xsl:if>
       </xsl:attribute>   
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 11, 2011 @ 18:36
    Dennis Aaen
    0

    Hi Fuji.

    Did you find a solution on how to add a class to subpages  so that the links will be indented

    /Dennis

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 12, 2011 @ 05:45
    Fuji Kusaka
    0

    Hi Dennis....

    I tried the above code in my previous post but its not indenting the subpages, the only thing working so far is the active current page.

    Any suggestion what i did wrong?

    //fuji

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 12, 2011 @ 13:15
    Dennis Aaen
    0

    Hi Fuji,
    I've tried some different things yesterday, but I did not find a solution on how you can get subpage to be indented.

    But hope you find a solution.
    /Dennis

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 16, 2011 @ 06:46
    Fuji Kusaka
    0

    Hey Dennis,

    Yes got it working, if you need some help on this i'll be please to share.

     

    //Fuji

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 18, 2011 @ 23:51
    Dennis Aaen
    0

    Hi Fuji,

    I know it is an old question. But I do not know if you found a solution.
    I have sat and tried to solve a similar question tonight and got the inspiration for the solution to your question.

    The code below gives you all the subpages for each page. These subpages is indented under the page they belong

    <ul>
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
     <xsl:if test="count(./ancestor-or-self::* [@isDoc][@level=3]/* [@isDoc and string(umbracoNaviHide) != '1']) &gt; 0">
      <ul id="subMenu">
        <xsl:for-each select="./ancestor-or-self::* [@isDoc and @level=3]/* [@isDoc and string(umbracoNaviHide) != '1']">
        <xsl:sort select="@sortOrder" order="ascending"/>
        <li>
          <a href="{umbraco.library:NiceUrl(current()/@id)}">
          <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id">
            <xsl:attribute name="class">selected</xsl:attribute>
          </xsl:if>
          <xsl:value-of select="current()/@nodeName"/>
          </a>    
        </li>
      </xsl:for-each>
      </ul>
      </xsl:if>
    </xsl:for-each>
    </ul>

    I'm not quite sure if it's the best way to solve this problem at.

    /Dennis

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 18, 2011 @ 23:59
    Dennis Aaen
    0

    Ahh hadn´t seen you found a solution to the issue. This may be another way to solve the same problem on.

    /Dennis

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 19, 2011 @ 09:34
    Fuji Kusaka
    0

    Hey Dennis,

    Yes got it working.....how about your solution is it working if not let me know ill try out.

     

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft