Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Jun 19, 2012 @ 03:30
    syn-rg
    0

    mediaCurrent macro parameter XSLT

    I have a very simple macro I'm using to pick PDF's from my media section and add them to the RTE.

    The parameter is "pdfFile" the mediatype is "PDF" and I'm not getting any results. I just want to create a simple download of the PDF file on the front-end.

    Can anyone assist me with this?
    Cheers, JV

    <?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:msxsl="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library"
      xmlns:synrg="urn:my-scripts"
      exclude-result-prefixes="msxml umbraco.library">
      <xsl:output method="xml" omit-xml-declaration="yes"/>
        
        <xsl:param name="currentPage" />
        <xsl:param name="pdfFile" select="/macro/mediaFolder/Folder/@id" />

        <xsl:template match="/">
          
          <xsl:if test="$currentPage/pdfFile != ''">
            <a href="{./umbracoFile}" title="{@nodeName}">
            <xsl:value-of select="umbraco.library:GetMedia($currentPage/pdfFile, 0)/umbracoFile"/>
            </a>
          </xsl:if>
        
        
      </xsl:template>
    </xsl:stylesheet>
  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 19, 2012 @ 04:38
    Fuji Kusaka
    0

    Hi, Try to change your xslt to this

    Add a variable name pdfFile for the parameter and test if media is present

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

    <xsl:template match="/">
      <xsl:if test="$pdfFile">   
        
        <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($pdfFile/*/@id, true())" />    
          <ul class="downloads">
             <xsl:for-each select="$pdfFile/File">         
            
                          <li><a href="{umbracoFile}" >
                                  <xsl:value-of select="@nodeName"/>
                              </a>                                     
                  </li>                         
          </xsl:for-each>
      </ul>
       </xsl:if>  
         
    </xsl:template>

     

    Hope this helps

  • syn-rg 282 posts 425 karma points
    Jun 19, 2012 @ 04:56
    syn-rg
    0

    Hi Fuji

    I tried your suggestion but I'm still not seeing anything on the front-end.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 19, 2012 @ 05:20
    Fuji Kusaka
    0

    Sorry my fault i just noticed you hava e mediaType "PDF", in the for-each change File to PDF

    <xsl:for-each select="$pdfFile/File">
    to
    <xsl:for-each select="$pdfFile/PDF">
  • 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