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>
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,
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).
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
is working on a reply...