Copied to clipboard

Flag this post as spam?

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


  • praveen 2 posts 22 karma points
    Jul 22, 2011 @ 06:37
    praveen
    0

    Show All Subfolders first image from media in umbraco 4.7.0

    Hi All,
              i want to show images from media folder in such a way
     
             in media my Main Folder such name
             Parient and under this folder it contain subfolder list such as
            
                Parient(MainFolder)----
                           Child1(SubFolder)---Image1,Image2,Image3,Image4,Image5,Image6,Image7,Image8
                           Child2(SubFolder)---Image1,Image2,Image3,Image4,Image5,Image6,Image7,Image8
                           Child3(SubFolder)---Image1,Image2,Image3,Image4,Image5,Image6,Image7,Image8
                           Child4(SubFolder)---Image1,Image2,Image3,Image4,Image5,Image6,Image7,Image8
                           Child5(SubFolder)---Image1,Image2,Image3,Image4,Image5,Image6,Image7,Image8
                           Child6(SubFolder)---Image1,Image2,Image3,Image4,Image5,Image6,Image7,Image8
     
               and i want to show Image1(As first image) from all subfolder. is this possible ,
              please help me.

    thanks,

    praveen

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 22, 2011 @ 07:45
    Dirk De Grave
    0

    praveen

    Sure this is possible, you'd need a double for-each to loop through all child nodes...

    <xsl:for-each select="umbraco.library:GetMedia($MainFolder, true())">
    <xsl:for-each select="umbraco.library:GetMedia(current()/@id, true())">
    <xsl:if test="position() = 1">
    <img src="./umbracoFile" />
    </xsl:if>
    </xsl:for-each>
    </xsl:for-each>

    First loop iterates folders of the MainFolder (either pass this is as a parameter on the xslt, or hard code this value in the xslt), inner loop fetches all child media nodes from the current node (Child1, Child2, ...) and gets the first image (using position() = 1)

    Second param to GetMedia() (true()) is to make sure the GetMedia() call returns all child nodes instead of fetching just a media node (in which case you'd use false())

    Hope this helps.

    Regards,

    /Dirk

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 22, 2011 @ 08:28
    Fuji Kusaka
    0

    Hey Praveen,

    You could also give this a tr. Same basic loop as Dirk mentioned earlier.

    <xsl:if test="$mediaFolder"> 
         <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($mediaFolder/*/@id, 'true')" />    
         <xsl:for-each select="$mediaItems/Image">     
           <xsl:if test="position() = 1">         
             <img src="./umbracoFile" />    
         </xsl:if>      
        </xsl:for-each>    
    </xsl:if

    //fuji

  • praveen 2 posts 22 karma points
    Jul 22, 2011 @ 08:37
    praveen
    0

    Hi Dirk,

                          thanks for your reply, i am new in umbraco,  but it can not show the images ,

            please check the xslt, and  xslt show this error

     

      

        

        <xsl:variable name="imageRoot" select="$currentPage/imageFolder"/>

      
    <xsl:for-each select="umbraco.library:GetMedia($imageRoot, true())">
    <xsl:for-each select="umbraco.library:GetMedia(current()/@id, true())">
    <xsl:if test="position() = 1">
    <img src="./umbracoFile" />
    xsl:if>
    xsl:for-each>
    xsl:for-each>

     

    thanks,

    praveen

Please Sign in or register to post replies

Write your reply to:

Draft