List images within media folders within top media folder
My users have images of weeds grouped and stored in media sub-folders by type (aquatic, ground plant, climber, bush, etc). Over these sub-folders there's a Weeds top level media folder.
For the parent Weed folder I'd like to output on a web page;
Weed Type: FOLDER-NAME1
image4 image1 image33
Weed Type: FOLDER-NAME2
image23 image8 image7
etc....
How do I iterate through each sub-folder for the parent Weed folder ? (I've no problem outputing weed images for a specific weed type sub-folder.)
Here is some example XSLT to get you started... I'm making an assumption that you are using Umbraco v4.5 with the new XML schema!
<!-- get the media id from somewhere? -->
<xsl:variable name="mediaId" select="1234" />
<!-- call GetMedia with the id and set the 'deep' parameter to true (or 1) -->
<xsl:variable name="rootFolder" select="umbraco.library:GetMedia($mediaId, 1)" />
<!-- check if there are any folders -->
<xsl:if test="$rootFolder/Folder">
<!-- loop through each folder -->
<xsl:for-each select="$rootFolder/Folder">
<!-- output the folder's title -->
<h1>
Weed Type: <xsl:value-of select="@nodeName" />
</h1>
<!-- check if there are any images -->
<xsl:if test="Image">
<!-- loop through each image -->
<xsl:for-each select="Image">
<!-- output the image tag HTML -->
<img src="{umbracoFile}" alt="{@nodeName}" height="{umbracoHeight}" width="{umbracoWidth}" />
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:if>
The idea here is that you call GetMedia with the mediaId and setting the 'deep' parameter to true - this should return all the child media nodes too.
Then it's a case of looping through each of the folders/images.
List images within media folders within top media folder
My users have images of weeds grouped and stored in media sub-folders by type (aquatic, ground plant, climber, bush, etc). Over these sub-folders there's a Weeds top level media folder.
For the parent Weed folder I'd like to output on a web page;
Weed Type: FOLDER-NAME1
image4 image1 image33
Weed Type: FOLDER-NAME2
image23 image8 image7
etc....
How do I iterate through each sub-folder for the parent Weed folder ?
(I've no problem outputing weed images for a specific weed type sub-folder.)
Help much appreciated.
Hi Chris,
Here is some example XSLT to get you started... I'm making an assumption that you are using Umbraco v4.5 with the new XML schema!
The idea here is that you call GetMedia with the mediaId and setting the 'deep' parameter to true - this should return all the child media nodes too.
Then it's a case of looping through each of the folders/images.
Let us know how you get on!
Cheers, Lee.
Hi Chris,
This should get you started - feel free to ask about the specifics, if you're curious:
/Chriztian
I like Chriztian's XSLT, it's much much better!
I was going to use xsl:apply-templates, but didn't want to seem to over-complicate it! ;-) haha
is working on a reply...