Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Dec 12, 2012 @ 07:32
    syn-rg
    0

    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>
    Any help would be greatly appreciated.
    Cheers, JV
  • syn-rg 282 posts 425 karma points
    Dec 12, 2012 @ 07:42
    syn-rg
    0
    <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>
  • syn-rg 282 posts 425 karma points
    Dec 12, 2012 @ 07:42
    syn-rg
    0

    <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>

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Dec 12, 2012 @ 08:39
    Chriztian Steinmeier
    0

    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

  • syn-rg 282 posts 425 karma points
    Dec 12, 2012 @ 09:19
    syn-rg
    0

    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:

    • 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>
  • syn-rg 282 posts 425 karma points
    Dec 13, 2012 @ 06:12
    syn-rg
    0

    I'm still trying to get this working, so far I can only get the following:

    • Logo
      • Masterbrand
      • Subbrand
    • 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)" />
    
         <div class="documentManager">
    
             <xsl:if test="$mediafolder !=''">
                 <xsl:variable name="files" select="umbraco.library:GetMedia($mediafolder, true())" />
                 <xsl:if test="$files != ''">
                     <ul>
                         <xsl:for-each select="$assetGroup//preValue">
                             <xsl:variable name="assetGroupValue" select="current()" />
                             <xsl:variable name="assetGroupList" select="$files//Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$assetGroupValue]" />
    
                             <li>
                                 <h3><xsl:value-of select="current()" /></h3><!-- Asset Group - assetGroupValue -->
    
                                 <xsl:if test="$assetGroupList != ''">
                                     <ul>
                                         <xsl:for-each select="$brand//preValue">
                                             <xsl:variable name="brandValue" select="current()" />
                                             <xsl:variable name="brands" select="Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$brandValue]" />
                                             <li>
                                                 <h3><xsl:value-of select="current()" /></h3><!-- Brand - brandValue -->
    
                                                 <xsl:if test="$brands != ''">
                                                     <ul>
                                                         <xsl:for-each select="$files//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>
    
                             </li>
                         </xsl:for-each>
    
                     </ul>
                 </xsl:if>
             </xsl:if>
         </div>
    
    </xsl:template>

     

    What I need it to do is the following:

    • 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 (If no Asset's have this value selected from "assetGroup" - Do not display in list.)
    • Icon
      • Masterbrand
        • Search icon
          • CMYK EPS
        • Help icon
          • CMYK EPS
      • Subbrand (If no Asset's have this value selected from "brand" - Do not display in list.)
    • Illustration
  • syn-rg 282 posts 425 karma points
    Dec 13, 2012 @ 07:23
    syn-rg
    0

    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
        • CMYK EPS - Alert icon - Subbrand
        • CMYK EPS - Help icon - Subbrand
    • Illustration

     

    <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)" />
    
         <div class="documentManager">
    
             <xsl:if test="$mediafolder !=''">
                 <xsl:variable name="files" select="umbraco.library:GetMedia($mediafolder, true())" />
    
                 <xsl:if test="$files != ''">
                     <ul>
                         <xsl:for-each select="$assetGroup//preValue">
                             <xsl:variable name="brandValue" select="current()" />
                             <xsl:variable name="assetGroupValue" select="current()" />
                             <xsl:variable name="assetGroupList" select="$files//Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$brandValue and chooseFileFormat=$assetGroupValue]" />
    
                             <xsl:variable name="brands" select="$files//Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$brandValue and chooseFileFormat=$assetGroupValue]" />
    
    
                             <xsl:variable name="documents" select="$files//Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$brandValue and chooseFileFormat=$assetGroupValue]/AssetVersion[@nodeTypeAlias = 'AssetVersion']" />
    
                             <li>
    
                                 <h3><xsl:value-of select="current()" /></h3><!-- Asset Group - assetGroupValue -->
    
                                 <xsl:if test="$brands != ''">
                                     <ul>
                                         <xsl:for-each select="$brand//preValue">
                                             <li>
                                                 <h3><xsl:value-of select="current()" /></h3>
    
                                                 <!--<xsl:copy-of select="$documents" />-->
    
                                                 <xsl:if test="$documents != ''">
                                                     <ul>
                                                         <xsl:for-each select="$documents">
                                                             <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>
    
                             </li>
                         </xsl:for-each>
    
                     </ul>
                 </xsl:if>
             </xsl:if>
         </div>
    
    </xsl:template>

     

    I hope this is clear, if not please let me know.

    Cheers, JV

  • syn-rg 282 posts 425 karma points
    Dec 14, 2012 @ 02:01
    syn-rg
    0

    I've got it displaying the following example:

    • Logo
      • Masterbrand
        • CMYK EPS
        • CMYK JPG
        • RGB JPG
        • RGB PNG
      • Subbrand
        • CMYK EPS
        • CMYK JPG
        • RGB JPG
        • RGB PNG
    • Artwork
    • Icon
      • Masterbrand
        • CMYK EPS - Search icon
        • CMYK EPS - Help icon
      • Subbrand
        • CMYK EPS - Alert icon
        • CMYK EPS - Help icon
    • Illustration

    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:

    • Logo - AssetchooseFileFormat value
      • Masterbrand - AssetchooseBrand value
        • Masterbrand primary logo - AssetsFoldername
          • CMYK EPS
          • CMYK JPG
          • RGB JPG
          • RGB PNG
      • Subbrand
        • Subbrand primary logo
          • CMYK EPS
          • CMYK JPG
          • RGB JPG
          • RGB PNG
    • Artwork
    • Icon
      • Masterbrand
        • Masterbrand search icon
          • CMYK EPS - Search icon
        • Masterbrand help icon
          • CMYK EPS - Help icon
      • Subbrand
        • Subbrand alert icon
          • CMYK EPS - Alert icon
        • Subbrand help icon
          • CMYK EPS - Help icon
    • Illustration
    <xsl:output method="xml" omit-xml-declaration="yes" />
    
    <xsl:param name="currentPage" />
    <xsl:param name="mediafolder" select="/macro/mediaFolder/AssetLibrary/@id" />
    <xsl:variable name="assetGroup" select="umbraco.library:GetPreValues(1468)" />
    <xsl:variable name="brand" select="umbraco.library:GetPreValues(1466)" />
    
     <xsl:template match="/"> 
    
         <div class="documentManager">         
             <xsl:if test="$mediafolder !=''">
                 <xsl:variable name="files" select="umbraco.library:GetMedia($mediafolder, true())" /> 
    
                 <xsl:if test="$files != ''">
                     <ul>
                         <xsl:for-each select="$assetGroup//preValue">
                             <xsl:variable name="assetGroupValue" select="current()" />
                             <xsl:variable name="assetGroupList" select="$files//AssetsFolder[@nodeTypeAlias = 'AssetsFolder']//Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$assetGroupValue]" />
                             <li>
                                 <h3><xsl:value-of select="current()" /></h3>
    
                                 <xsl:if test="$assetGroupList != ''">
                                     <ul>
                                         <xsl:for-each select="$brand//preValue">
                                             <xsl:variable name="brandValue" select="current()" />
                                             <li>
                                                 <h3><xsl:value-of select="current()" /></h3>
                                                 <xsl:variable name="brands" select="$files//AssetsFolder[@nodeTypeAlias = 'AssetsFolder']//Asset[@nodeTypeAlias = 'Asset' and chooseFileFormat=$assetGroupValue and chooseBrand=$brandValue]" />
                                                 <xsl:if test="$brands != ''">
                                                     <ul>
                                                         <xsl:for-each select="$brands//AssetVersion[@nodeTypeAlias = 'AssetVersion']">
                                                             <li>
                                                                 <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>
                             </li>
                         </xsl:for-each>
                     </ul>
                 </xsl:if>
             </xsl:if>
         </div> 
    </xsl:template>
    
    </xsl:stylesheet>
Please Sign in or register to post replies

Write your reply to:

Draft