Copied to clipboard

Flag this post as spam?

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


  • René 327 posts 852 karma points
    May 24, 2012 @ 22:52
    René
    0

    MediaPicker - Get value from site parameter

    Hi 

    Umbraco ver 4.7.2

    I am stuggeling to get this working, any help would help.

    I need to get this to work. I know ther is a lot in the forum about this issue, i have searced a lot and trying all sorts of solutions. I just cant get it to work.

    I have created mediaPicker in the document type with the alias as mediaFolderID.

     <xsl:variable name="mediaFolder" select="$currentPage/mediaFolderID"/>

     

    When i use the xslt parameter like this it is working great.

    <xsl:variable name="mediaFolder" select="/macro/mediaFolder" />

     

    Here is the complete xslt code:

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
            version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:umb="urn:umbraco.library"
            exclude-result-prefixes="umb"
            >

            <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

            <xsl:param name="currentPage" />
             
            <!--<xsl:variable name="mediaFolder" select="$currentPage/mediaFolderID"/>-->
                
            <xsl:variable name="mediaFolder" select="/macro/mediaFolder" />
            
            <xsl:template match="/">
              <xsl:if test="$mediaFolder[Folder]">
                <xsl:variable name="media" select="umb:GetMedia($mediaFolder/Folder/@id, true())" />
                  <!-- If no errors, this will run the Folder template below -->
                <xsl:apply-templates select="$media[not(error)]" />
                            
            </xsl:if>
            </xsl:template>
            
            <!-- Template for the folder -->
            <xsl:template match="Folder">
                    
                            <!-- Run templates for individual items (just add Media type aliases) -->
                            <xsl:apply-templates select="File | Image" />
              
             
            </xsl:template>
            
            <!-- Template for items - you can create individual templates to render them differently -->
             <xsl:template match="File | Image">
              <xsl:text />{ src: '<xsl:value-of select="umbracoFile" />', fade: 4000}<xsl:text />
              <xsl:if test="not(position() = last())"></xsl:if>
            </xsl:template>
            </xsl:stylesheet>         

     

    Tanks in advance

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 25, 2012 @ 00:57
    Chriztian Steinmeier
    0

    Hi René,

    When you use /macro/mediaFolder you get XML back - when you're using a Media Picker, you only get the id, so that's what you need to feed the GetMedia() function:

    <xsl:variable name="mediaFolder" select="$currentPage/mediaFolderID" />
    
    <xsl:template match="/">
        <xsl:if test="normalize-space($mediaFolder)">
            <xsl:variable name="media" select="umb:GetMedia($mediaFolder, true())" />
            <!-- If no errors, this will run the Folder template below -->
            <xsl:apply-templates select="$media[not(error)]" />
        </xsl:if>
    </xsl:template>

    /Chriztian

  • René 327 posts 852 karma points
    May 25, 2012 @ 08:38
    René
    0

    Tanks a lot.

    It is working.. and i am learning.

    Kindly René

Please Sign in or register to post replies

Write your reply to:

Draft