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 @ 09:50
    René
    0

    Get media with Parameter from page

    Hi 

    Umb ver 4.7.2

    MsSql 2008

    I am trying to get a list of image to load form a folder with xslt... (One moe time.... )

    Here is the 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="/macro/mediaFolder" />-->
      <xsl:variable name="mediaFolder" select="$currentPage/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">
             <href="{umbracoFile}"><img src="{umbracoFile}" /></a>  
            </xsl:template>
     </xsl:stylesheet

    I want to get the parameter value from the current document. Where i have this in the document type

    Tab: Background images

    • Edit "mediaFolder"

      Name
      Alias
      Type
      Tab
      Mandatory
      Description
      -

    How do i get to select the macro "mediafolder " from the current document. 

    I have been trying the last days to get to work.. Now i need a a little help

    Tanks to all of you in here at our.umbraco.

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    May 29, 2012 @ 22:26
    Chriztian Steinmeier
    100

    Hi René,

    The XSLT you have was written for use with a macro parameter called "mediaCurrent" - to make it work with a media picker instead, change the root template to this:

    <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>

    Let us know if it works!

    /Chriztian

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies