Listing files from media within folder structure XSLT
I'm trying to list files from the Media section, and have seperated the files into groups using a dropdown list preValue. I then list all the files with that selected preValue into that group.
However, my folder structure in the Media section has been created so that related files are uploaded into the same folder. I would the front end to display these items within their own list, but titled under their parent folder nodeName.
I have created 4 mediaTypes, structured in the following:
Asset Library
Assets Folder *
Asset
Asset Version
*Assets Folder's can be child nodes of themselves, and therefor the folder structure can be very deep.
Here's an example of what I need:
Logo
Primary logo
CMYK EPS
CMYK JPG
RGB JPG
RGB PNG
Alternative logo
CMYK EPS
CMYK JPG
RGB JPG
RGB PNG
Artwork
Icon
Currently my XSLT is displaying the following:
Logo
Primary logo
CMYK EPS
Primary logo
CMYK JPG
Primary logo
RGB JPG
Primary logo
RGB PNG
Alternative logo
CMYK EPS
Alternative logo
CMYK JPG
Alternative logo
RGB JPG
Alternative logo
RGB PNG
Artwork
Icon
I can't figure out how to check if the AssetVersions, parent Asset has siblings within the parent AssetsFolder. And if it does, to display them within the same list, instead of seperately.
Here's my XSLT so far:
<xsl:param name="currentPage" />
<xsl:param name="mediafolder" select="/macro/mediaFolder/AssetLibrary/@id" />
<xsl:template match="/">
<xsl:variable name="assetGroup" select="umbraco.library:GetPreValues(1468)" />
<xsl:if test="$mediafolder !=''">
<xsl:variable name="files" select="umbraco.library:GetMedia($mediafolder, true())" />
<!-- Uncomment this for DEBUG and view the HTML source of your page to see the XML snippet -->
<!--<xsl:copy-of select="$files" />-->
<xsl:if test="$files != ''">
<ul>
<xsl:for-each select="$assetGroup//preValue">
<xsl:variable name="assetGroupValue" select="current()" />
<xsl:variable name="assets" select="$files//Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$assetGroupValue]" />
<li>
<h3><xsl:value-of select="current()" /></h3>
<xsl:if test="$assets != ''">
<ul>
<xsl:for-each select="$assets//AssetVersion[@nodeTypeAlias = 'AssetVersion']">
<li>
<h4><xsl:value-of select="../../@nodeName" /></h4>
<a href="{./umbracoFile}" class="external">
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:if>
</xsl:template>
Thanks for helping. I'll clarify a few items for you.
* "Logo", "Artwork" and "Icon" are properties of the Asset mediaType from the "assetGroup" dropdown list.
AssetsFolder items (does it have the single "s" in there)? Yes it has the "s" in there
* "Primary logo" and "Alternative logo" are AssetFolder items, these are the folders Asset mediaTypes are created.
* "CMYK EPS", "RGB JPG" etc. are AssetVersion items ? Yes these are AssetVersion items (but named from properties within the AssetVersion instead of it's @nodeName)
Below is an example of the Media folder structure. AP Logo Suite is an AssetsFolder You'll notice the Asset and AssetVersion are named the same, purely a file naming convention.
Also I have another drop down list property on the Asset that I would like to include in the front-end list:
Here's an example of what I need:
Logo
Masterbrand
Primary logo
CMYK EPS
CMYK JPG
RGB JPG
RGB PNG
Alternative logo
CMYK EPS
CMYK JPG
RGB JPG
RGB PNG
Subbrand
Primary logo
CMYK EPS
CMYK JPG
RGB JPG
RGB PNG
Alternative logo
CMYK EPS
CMYK JPG
RGB JPG
RGB PNG
Artwork
Icon
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage" />
<xsl:param name="mediafolder" select="/macro/mediaFolder/AssetLibrary/@id" />
<xsl:template match="/">
<xsl:variable name="brand" select="umbraco.library:GetPreValues(1466)" />
<xsl:variable name="assetGroup" select="umbraco.library:GetPreValues(1468)" />
<xsl:if test="$mediafolder !=''">
<xsl:variable name="files" select="umbraco.library:GetMedia($mediafolder, true())" />
<!-- Uncomment this for DEBUG and view the HTML source of your page to see the XML snippet -->
<!--<xsl:copy-of select="$files" />-->
<xsl:if test="$files != ''">
<ul>
<xsl:for-each select="$assetGroup//preValue">
<xsl:variable name="assetGroupValue" select="current()" />
<xsl:variable name="assets" select="$files//Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$assetGroupValue]" />
<li>
<h3><xsl:value-of select="current()" /></h3>
<xsl:if test="$assets != ''">
<ul>
<xsl:for-each select="$assets//AssetVersion[@nodeTypeAlias = 'AssetVersion']">
<li>
<h4><xsl:value-of select="../../@nodeName" /></h4>
<a href="{./umbracoFile}" class="external">
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
This option gives me all the AssetVersions, but it repeats them in every "brand" within the "assetGroup", and doesn't group them together if they are from the same AssetsFolder:
Logo
Masterbrand
CMYK EPS - Masterbrand
CMYK JPG - Masterbrand
RGB JPG - Masterbrand
RGB PNG - Masterbrand
CMYK EPS - Subbrand - Shouldn't appear in this list
CMYK JPG - Subbrand - Shouldn't appear in this list
RGB JPG - Subbrand - Shouldn't appear in this list
RGB PNG - Subbrand - Shouldn't appear in this list
Subbrand
CMYK EPS - Masterbrand - Shouldn't appear in this list
CMYK JPG - Masterbrand - Shouldn't appear in this list
RGB JPG - Masterbrand - Shouldn't appear in this list
RGB PNG - Masterbrand - Shouldn't appear in this list
CMYK EPS - Subbrand
CMYK JPG - Subbrand
RGB JPG - Subbrand
RGB PNG - Subbrand
Artwork (If no Asset's have this value selected from "assetGroup" - Do not display in list.)
Icon
Masterbrand
CMYK EPS - Search icon - Masterbrand
CMYK EPS - Help icon - Masterbrand
CMYK EPS - Alert icon - Subbrand - Shouldn't appear in this list
CMYK EPS - Help icon - Subbrand - Shouldn't appear in this list
Subbrand (If no Asset's have this value selected from "brand" - Do not display in list.)
CMYK EPS - Search icon - Masterbrand - Shouldn't appear in this list
CMYK EPS - Help icon - Masterbrand - Shouldn't appear in this list
Listing files from media within folder structure XSLT
I'm trying to list files from the Media section, and have seperated the files into groups using a dropdown list preValue. I then list all the files with that selected preValue into that group.
However, my folder structure in the Media section has been created so that related files are uploaded into the same folder. I would the front end to display these items within their own list, but titled under their parent folder nodeName.
I have created 4 mediaTypes, structured in the following:
*Assets Folder's can be child nodes of themselves, and therefor the folder structure can be very deep.
Here's an example of what I need:
Currently my XSLT is displaying the following:
Cheers, JV
<xsl:param name="currentPage" />
<xsl:param name="mediafolder" select="/macro/mediaFolder/AssetLibrary/@id" />
<xsl:template match="/">
<xsl:variable name="assetGroup" select="umbraco.library:GetPreValues(1468)" />
<xsl:if test="$mediafolder !=''">
<xsl:variable name="files" select="umbraco.library:GetMedia($mediafolder, true())" />
<!-- Uncomment this for DEBUG and view the HTML source of your page to see the XML snippet -->
<!--<xsl:copy-of select="$files" />-->
<xsl:if test="$files != ''">
<ul>
<xsl:for-each select="$assetGroup//preValue">
<xsl:variable name="assetGroupValue" select="current()" />
<xsl:variable name="assets" select="$files//Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$assetGroupValue]" />
<li>
<h3><xsl:value-of select="current()" /></h3>
<xsl:if test="$assets != ''">
<ul>
<xsl:for-each select="$assets//AssetVersion[@nodeTypeAlias = 'AssetVersion']">
<li>
<h4><xsl:value-of select="../../@nodeName" /></h4>
<a href="{./umbracoFile}" class="external">
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:if>
</xsl:template>
Hi JV,
I'd love to help you through this - but I need to know what the "bits" are - so am I right in assuming this:
* "Logo", "Artwork" and "Icon" are AssetsFolder items (does it have the single "s" in there)?
* "Primary logo" and "Alternative logo" are Asset items ?
* "CMYK EPS", "RGB JPG" etc. are AssetVersion items ?
Could you show how the example you're referring to is actually stored in the various folders in Media?
/Chriztian
Hi Chriztian,
Thanks for helping. I'll clarify a few items for you.
* "Logo", "Artwork" and "Icon" are properties of the Asset mediaType from the "assetGroup" dropdown list.
AssetsFolder items (does it have the single "s" in there)? Yes it has the "s" in there
* "Primary logo" and "Alternative logo" are AssetFolder items, these are the folders Asset mediaTypes are created.
* "CMYK EPS", "RGB JPG" etc. are AssetVersion items ? Yes these are AssetVersion items (but named from properties within the AssetVersion instead of it's @nodeName)
Below is an example of the Media folder structure.
AP Logo Suite is an AssetsFolder
You'll notice the Asset and AssetVersion are named the same, purely a file naming convention.
Also I have another drop down list property on the Asset that I would like to include in the front-end list:
Here's an example of what I need:
I'm still trying to get this working, so far I can only get the following:
What I need it to do is the following:
This option gives me all the AssetVersions, but it repeats them in every "brand" within the "assetGroup", and doesn't group them together if they are from the same AssetsFolder:
I hope this is clear, if not please let me know.
Cheers, JV
I've got it displaying the following example:
All I need to do is figure out how to get the Asset's which have siblings within the same AssetsFolder to display grouped together in a list:
is working on a reply...