get the Content of an Folder Options
thahammer
Posted: Friday, May 09, 2008 11:44:36 AM

Rank: Aficionado

Joined: 8/28/2007
Posts: 121
Location: Bavaria
How can i make this?

A Customer wants an Donwload Area. Ok i can manage the Login Thing over Members and the Member Package. I found this coll Video (no Sound at all) http://hartvig.com/screencasts/members.htm

But i need something who gives me the complete Content of an Folder.

My Customer wants to copy all Files into this Folder, and his Customers should be able to download them.
So i thought, i make an makro for the protected Page (remember the Member Thing!) which reads the whole Content out of the Download Folder.

Quote:

<xsl:if test="position() !=last()">

</xsl:if>


I thought about something like this, but how to say, get the Content from this Folder?

I Love umbraco
racer.x
Posted: Friday, May 09, 2008 2:07:27 PM

Rank: Devotee

Joined: 7/20/2006
Posts: 67
Location: Nürnberg, Germany
Hi thahammer
you can achieve this by uploading the files into a folder in the Media section.

In the according doctype you have to setup a mediapicker with the alias e.g. "documents".
With the mediapicker you choose the folder where the files are stored.

To show the list of files you use a xslt like this:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="msxml umbraco.library">
    
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="docFolder" select="number($currentPage/data [@alias = 'documents'])"/>
<xsl:template match="/">

<xsl:if test="$currentPage/data [@alias = 'documents'] != 0">
    <h2><xsl:value-of select="$currentPage/data [@alias = 'docHeadline']" /></h2>
    <dl id="listNavigation">
    <xsl:for-each select="umbraco.library:GetMedia($docFolder, 'true')/node">
        <dd>
        <a href="{./data [@alias='umbracoFile']}">
        <xsl:value-of select="./data [@alias='docTitle']" />
        </a> (.<xsl:value-of select="./data [@alias = 'umbracoExtension']" />, <xsl:value-of select="round((./data [@alias = 'umbracoBytes']) div 1024)" /> KB)
        </dd>
    </xsl:for-each>
    </dl>
</xsl:if>
</xsl:template>
</xsl:stylesheet>


Hope this helps
Horst
thahammer
Posted: Friday, May 09, 2008 2:24:30 PM

Rank: Aficionado

Joined: 8/28/2007
Posts: 121
Location: Bavaria
This sounds cool! I will try this. Thanks a lot! Angel

I Love umbraco
thahammer
Posted: Wednesday, May 14, 2008 11:58:59 AM

Rank: Aficionado

Joined: 8/28/2007
Posts: 121
Location: Bavaria
Ok it´s working.

But with one Error, it shows me no Filename.

Quote:
<xsl:value-of select="./data [@alias='docTitle']" />


This Value is empty. Comes it from the DocType?

I Love umbraco
VirtualRichard
Posted: Wednesday, May 14, 2008 12:15:12 PM

Rank: Aficionado

Joined: 9/17/2007
Posts: 119
Location: London, UK.
Right off the top of my head, so maybe not correct: [@alias = 'umbracoFile']

Take a look at Tim Gaunt's random image stylesheet. There's some really good stuff in there for pillaging.

Richard

2 * 3 * 3 * 37 : The prime factorisation of The Beast.
thahammer
Posted: Wednesday, May 14, 2008 1:46:56 PM

Rank: Aficionado

Joined: 8/28/2007
Posts: 121
Location: Bavaria
VirtualRichard wrote:
Right off the top of my head, so maybe not correct: [@alias = 'umbracoFile']

Take a look at Tim Gaunt's random image stylesheet. There's some really good stuff in there for pillaging.

Richard


This one don´t solve my Problem. I have to grab the Name of the File and gave it to the Output.

This one gave me the complete Path to the File: [@alias = 'umbracoFile']

So how can i grab now the Name of the File?

I Love umbraco
Richard
Posted: Wednesday, May 14, 2008 3:38:26 PM
Rank: Enthusiast

Joined: 9/7/2007
Posts: 15
Location: UK
@nodeName will give you the name of the file/node, where data[@alias='umbracoFile'] will give the path to the file.
racer.x
Posted: Wednesday, May 14, 2008 3:43:36 PM

Rank: Devotee

Joined: 7/20/2006
Posts: 67
Location: Nürnberg, Germany
...it's a mediatype property (Settings/media Types)
you can setup your own or use one of the default and add a property like this.

cheers, horst
racer.x
Posted: Wednesday, May 14, 2008 3:47:39 PM

Rank: Devotee

Joined: 7/20/2006
Posts: 67
Location: Nürnberg, Germany
...the solution of richard is good if you dont't want to edit each single file and give a "docTitle"
But you could use both - if docTitle is empty use fileName

cheers, horst
thahammer
Posted: Wednesday, May 14, 2008 3:57:18 PM

Rank: Aficionado

Joined: 8/28/2007
Posts: 121
Location: Bavaria
Richard wrote:
@nodeName will give you the name of the file/node, where data[@alias='umbracoFile'] will give the path to the file.


It´s to Hot here. So simple at all. Yes it was a simple @nodeName.

Thanks a lot Applause

I Love umbraco
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.