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 06, 2012 @ 07:37
    syn-rg
    0

    Download all files within media folder

    I've created a macro that lists all the files within a chosen media folder, using XSLT in 4.9.0

    Each file can be downloaded using a href = "{./umbracoFile}"

    Is there anyway I can add a button/link so that all files can be downloaded at once?
    Would be nice if they could be zipped but not necessary (could just download multiple files).

    <xsl:template match="/">
      <!--<p> <b>mediaFolder:</b> <xsl:value-of select="$mediafolder" /> </p>-->
    
      <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 != ''">
          <div class="download-container"> 
            <!-- For each XML node <node> where the nodeTypeAlias attribute = File -->
            <xsl:for-each select="$files/Folder/Download[@nodeTypeAlias = 'Folder']">
              <a href="{./umbracoFile}"> <xsl:value-of select="@nodeName" /> </a>
            </xsl:for-each>
          </div>
        </xsl:if>
      </xsl:if>
    </xsl:template>

     

  • Chriztian Steinmeier 2798 posts 8787 karma points MVP 7x admin c-trib
    Dec 06, 2012 @ 10:40
    Chriztian Steinmeier
    0

    Hi JV,

    You may be able to find some .NET code for zipping up the files — the packaging system in the Back-office definitely use some kind of zip library, but I have no clue where it's at.

    If you manage to find it, you could create a new template called "all" for rendering the ZIP byte-stream, and use that as an altTemplate - e.g. if your "downloads list" is at /downloads/pdf/ you can just link to /downloads/pdf/all/ and the "all" template will be used to render the /downloads/pdf/ page.

    Hope that gets you a litle further towards a solution,

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft