Copied to clipboard

Flag this post as spam?

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


  • Christian Tarrild 23 posts 43 karma points
    May 27, 2010 @ 11:12
    Christian Tarrild
    0

    Select media folder in macro with currentMedia

    Hi

    I am using umbraco 4.0.4.1 and I want to make a macro to list files in a specific media folder. The contenteditor can add the macro in the editor and choose the folder from where he want's to list the content. I am using the currentMedia parameter type in the macro. My problem is when I select a folder currentMedia does not return anything. I have this xslt where folder is the currentMedia type.

    <xsl:copy-of select="/macro/folder"/>

    When is choose a specific file it returns the file name and location , but when I choose a folder it returns nothing. 

    I have tried debugging the macro by adding ?umbDebug=true which returns this:

    <macro><Mappe><node id="1261" version="468943c0-cc40-4c2a-87e8-fa728cc86dc4" parentID="1260" level="2" writerID="2" nodeType="1031" template="0" sortOrder="1" createDate="2010-05-24T23:55:54" updateDate="2010-05-24T23:55:54" nodeName="Elite dokumenter" urlName="elitedokumenter" writerName="Christian Tarrild" nodeTypeAlias="Folder" path="-1,1260,1261"><data alias="contents" /></node></Mappe></macro>

    How can i access the information?

    Regards Tarrild

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    May 28, 2010 @ 01:21
    Chriztian Steinmeier
    0

    Hi Christian,

    You should be able to do something like this:

    <xsl:variable name="folderNode" select="umbraco.library:GetMedia(/macro/Mappe/node/@id, true())" />
    
    <!-- Process nodes in folder -->
    <xsl:apply-templates select="$folderNode/node" />
    
    <!-- Output for a single Image
    <xsl:template match="node[@nodeTypeAlias = 'Image']">
        <img src="{data[@alias = 'umbracoFile']}" width="{data[@alias = 'umbracoWidth']}" height="{data[@alias = 'umbracoHeight']}" />
    </xsl:template>
    
    <!-- Templates for other types ... -->

    /Chriztian

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    May 28, 2010 @ 01:23
    Chriztian Steinmeier
    0

    Yeah - there was a glitch in The Matrix as I posted that... should be:

    <xsl:variable name="folderNode" select="umbraco.library:GetMedia(/macro/Mappe/node/@id, true())" />
    
    <!-- Process nodes in folder -->
    <xsl:apply-templates select="$folderNode/node" />
    
    <!-- Template for a single Image -->
    <xsl:template match="node[@nodeTypeAlias = 'Image']">
        <img src="{data[@alias = 'umbracoFile']}" width="{data[@alias = 'umbracoWidth']}" height="{data[@alias = 'umbracoHeight']}" />
    </xsl:template>
    
    <!-- Templates for other types ... -->

    /Chriztian

  • Christian Tarrild 23 posts 43 karma points
    May 28, 2010 @ 09:40
    Christian Tarrild
    0

    Thank you Chriztian. Worked like a charm :)

Please Sign in or register to post replies

Write your reply to:

Draft