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
    Apr 12, 2012 @ 10:13
    Fuji Kusaka
    0

    Display Only Child Nodes

    Am stuggling with this Xslt and cant figure a way out.

    Here is the situation and am trying to display only Child Nodes instead of Parent node by using GetXmlNodeById

    Folder Content (id= 1755 )
    Folder News 1
    News Item 1
    News Item 2
    Folder News 2 
    News Item 1
    News Item 2
    Folder News 3
    News Item 1
    News Item 2

    I only want to display the Child nodes of Folder News 1, Folder News 2 and Folder News 3.

     <xsl:for-each select="umbraco.library:GetXmlNodeById($level)//* [@isDoc]">
        <xsl:sort select="@createDate" order="descending" />
       <li>
        <xsl:value-of select="@nodeName"/>
        </li>
          <li<xsl:call-template name="ImageGallery"/> </li
      </xsl:for-each>

    Instead am getting both the Folder and item Name. Any help on this please?

     

  • Steffen Agger 13 posts 34 karma points
    Apr 12, 2012 @ 13:03
    Steffen Agger
    1

    xpath:

    "/" Selects children from the root node
    "//" Selects descendants from the root node

    So without any knowledge about xslt, i think you could do : umbraco.library:GetXmlNodeById($level)/*[@isDoc]

    also, you might wanna check these examples : http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema

  • Steffen Agger 13 posts 34 karma points
    Apr 12, 2012 @ 19:52
    Steffen Agger
    0

    wait... did you only want to show the items or the folders ? if items - it would be umbraco.library:GetXmlNodeById($level)/*[@isDoc]/*[@isDoc]

    *could/should be replaces by document types...

     

    i think... again not an xslt guy, but that xpath should match.

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 12, 2012 @ 19:58
    Fuji Kusaka
    0

    Hi Steffen,

    I got this working what i did is 

    <xsl:for-each select="umbraco.library:GetXmlNodeById($level)//* [@isDoc][not(umbracoNaviHide = 1)]">
        <xsl:sort select="@createDate" order="descending" />   
          <xsl:call-template name="linkItems"/>
          <href="{umbraco.library:NiceUrl(@id)}"><xsl:call-template name="ImageGallery"/> </a>
      </xsl:for-each>    
    </xsl:template>
        
        
          <!-- Template for the image -->
     <xsl:template name="ImageGallery">
       <xsl:variable name="mediapickerproperty" select="./galleryPicker"/>   
      <xsl:variable name="numMedia" select="4"/>         
           <xsl:if test="$mediapickerproperty &gt; 0">                
                      <xsl:for-each select="umbraco.library:GetMedia($mediapickerproperty, 1)/PhotoGallery[1]">
                         <xsl:if test="position() &lt;= $numMedia" >
                                   <img src="{umbraco.library:Replace(umbraco.library:GetMedia(@id, 0)/umbracoFile, '.', '_Thumbnail.')}"/>
                           </xsl:if>    
                  </xsl:for-each>            
        </xsl:if>   
    </xsl:template>
        <!-- Display only Nodes with Document Type "Album" -->
        <xsl:template name=" linkItems ">
          <xsl:if test="self::Album">
            <href="{umbraco.library:NiceUrl(@id)}"<xsl:value-of select="@nodeName"/> </a>
          </xsl:if>
        </xsl:template>

    So from my current page i get all the attributes from the Child Nodes then i just make a sorting to get the most current @createDate which will go through all Parents nodes checking for new documents created

    //fuji

  • 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