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 @ 09:51
    Fuji Kusaka
    0

    Viewing Child Nodes

    Hi all am having some issues with displaying nodes from a Changeable XSLT.

    I just changed my content tree to

    * Content

    ** Default

    ** Folder 1

    // Sub Link 1

    // Sub Link 2

    ** Folder 2

    // Sub Link 1

    // Sub Link 2

       /// Sub Sub Link 2

       /// Sub Sub Link 2

    // Sub Link 3

        /// Sub Sub Link 2

       /// Sub Sub Link 3

     

    This is the code am using in my XSLT but i can get the nodes to display

     

    <xsl:variable name="maxLevel" select="3" />
      
      <xsl:template match="/">
        <ul>
         
      
          
          <xsl:call-template name="drawNodes">  
            <xsl:with-param name="parent" select="$currentPage/descendant-or-self::* [@isDoc and @level and string(umbracoNaviHide) != '1']"/>  
          </xsl:call-template>
        
        </ul>
      </xsl:template>
      
      <xsl:template name="drawNodes">
        <xsl:param name="parent"/>   
        <xsl:if test="$parent/@level &lt; $maxLevel">
          <!--<ul>-->
            <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1']">
              <li>             
              <a>
                 <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl(@id)"/></xsl:attribute>
                 <xsl:value-of select="@nodeName"/>
              </a>
                
              </li>
                <!-- check if this is the current page AND if this has a child - if so run through again -->
                <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>
          <!--</ul>-->
        </xsl:if>
       
      </xsl:template>


    //fuji

  • Rich Green 2246 posts 4008 karma points
    Jun 09, 2011 @ 11:09
    Rich Green
    0

    Hey Fuji,

    I would try the default SiteMap xlst and see how that works.

    Rich

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 12:03
    Fuji Kusaka
    0

    Rich,

    I tried it but it wont give me the display same node when am on the default page.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 12:18
    Fuji Kusaka
    0

    I have tried to change the XSLT but still nothing showing up, when am on the homepage.

     

    Any advise please

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

    Rich,

    Can you help me with that?? Am not getting the same output when am on other pages...can you tell me how to i display all the nodes of a parent and nodes of its child?

     

     

  • Rich Green 2246 posts 4008 karma points
    Jun 09, 2011 @ 13:14
    Rich Green
    0

    Hey Fuji,

    Can you post an image of your content structure?

    Rich

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 13:23
    Fuji Kusaka
    0

    Hey Rich,

     

    Basically I want to display all the nodes from Folder 2, but right now when am using this piece of code to draw all the nodes it giving me the nodes of from the currentPage am on and using a changeable XSLT

     

  • Rich Green 2246 posts 4008 karma points
    Jun 09, 2011 @ 13:27
    Rich Green
    0

    Hey Fuji,

    In my opinion your structure is causing the problems.

    Every Folder (1,2,3,4,5) in your structure is getting treated as a separate site.

    How about changing your structure to:

    - Default (Home)

    - Folder 1

    - Folder 2

    - Etc.

    - Members

    I think you'll find your xslt will work better this way.

    Rich

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 13:32
    Fuji Kusaka
    0

    Rich,

     

    But under my default (home) i will have more nodes there, those Folder 1 ~ Folder 2 are Galleries, Links that needs to be visible on every pages.

     

    //fuji

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

    Is there a way of displaying the child node of a specific parent node, instead of usint $currentPage?

  • Rich Green 2246 posts 4008 karma points
    Jun 09, 2011 @ 13:42
    Rich Green
    0

    Hey Fuji,

    That's exactly what 'List Sub Pages by Changeable source does"

    <!--Change this <xsl:variable name="source" select="/macro/source"/> -->
    
    <!--Change this to use node id-->
    
    <xsl:variable name="source" select="1020"/>
    
    <xsl:template match="/">
    
    <!-- The fun starts here -->
    <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>
  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 15:32
    Fuji Kusaka
    0

    Rich,

     

    Am getting only the Child nodes not even the parents. that is only the sub sub Links. Like my screenshot above am no getting the

    Charter, Chair but only the Sub Like Structure , Secretary, Rules of Procedure

     

    Fuji

     

     

  • Rich Green 2246 posts 4008 karma points
    Jun 09, 2011 @ 15:42
    Rich Green
    0

    That's because it's just showing the child nodes, it's not recursive.

    You need to use recursive like the Site Map XSLT.

    Rich

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 15:46
    Fuji Kusaka
    0

    Thats what am using..

     

    <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 @level=2 and string(umbracoNaviHide) != '1']"/>  
        </xsl:call-template>
    </ul>
    </xsl:template>

    <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
      
    <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
    <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel]">
        <li>  
            <a href="{umbraco.library:NiceUrl(@id)}">
              <xsl:value-of select="@nodeName"/>
            </a>  
          
          <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level = 2 &lt;= $maxLevel]) &gt; 0">   
            <xsl:call-template name="drawNodes">    
                <xsl:with-param name="parent" select="."/>    
            </xsl:call-template>  
          </xsl:if>
        </li>
    </xsl:for-each>
      
    </xsl:if>
      
    </xsl:template>
  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 09, 2011 @ 16:04
    Fuji Kusaka
    0

    Thats what am using..

     

    <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 @level=2 and string(umbracoNaviHide) != '1']"/>  
        </xsl:call-template>
    </ul>
    </xsl:template>

    <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
      
    <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
    <xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level &lt;= $maxLevel]">
        <li>  
            <a href="{umbraco.library:NiceUrl(@id)}">
              <xsl:value-of select="@nodeName"/>
            </a>  
          
          <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level = 2 &lt;= $maxLevel]) &gt; 0">   
            <xsl:call-template name="drawNodes">    
                <xsl:with-param name="parent" select="."/>    
            </xsl:call-template>  
          </xsl:if>
        </li>
    </xsl:for-each>
      
    </xsl:if>
      
    </xsl:template>
Please Sign in or register to post replies

Write your reply to:

Draft