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())
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
praveen
Sure this is possible, you'd need a double for-each to loop through all child nodes...
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
Hey Praveen,
You could also give this a tr. Same basic loop as Dirk mentioned earlier.
//fuji
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
is working on a reply...