Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 30, 2011 @ 15:38
    Fuji Kusaka
    0

    Media File

    Hi there,

     

    Can someone help me sorting out how to display Media Files (pdf) which i previously added in the Media Content. My approched was to create a XSLT files and make use of the Macro in my editor by using the Type mediaCurrent to access specific Folder in the Media diretory where it will display a list of pdf but nothing is showing up.

    I tried  GetMedia but still nothing.

    Any advise please?

     

    //fuji

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 30, 2011 @ 15:49
    Tom Fulton
    0

    Hi Fuji,

    mediaCurrent is a little tricky, it returns the XML for the media item you select, but not it's children.  So you need to use GetMedia to get the children.

    Ex:

    <xsl:variable name="mediaFolder" select="/macro/yourParam" />
     
    <xsl:if test="$mediaFolder">
      <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($mediaFolder/*/@id, true())"/>
     
      <xsl:for-each select="$mediaItems/Image">
        <xsl:value-of select="@nodeName"/> - <img src="{umbracoFile}" />
      </xsl:for-each>

    </xsl:if>

    -Tom

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 30, 2011 @ 16:13
    Fuji Kusaka
    0

    Hi Tom,

    Am all confused!!! What am trying to do is insert a macro in my editor which will display all the pdf in my media section.

     

    //fuji

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 30, 2011 @ 16:27
    Tom Fulton
    0

    The above should work for that, just change /Image to /File or whatever the alias of your PDF media types are.  And get rid of the <img ..>

    You'll need to add a parameter to the macro in Developer -> Macros -> (Your Macro), of type mediaCurrent, and place the alias in place of "yourParam" in the above example.  Then check the "Allow in editor" box and you should be able to insert it into the editor, and use the mediaCurrent param to select the folder that contains your PDFs.

    Does that make sense?

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 30, 2011 @ 16:42
    Fuji Kusaka
    0

    Thanks Tom, 

    But still not getting anything. Here is how i did it.

    1. create XSLT (clean) then in my Macro I Alias(pdfFiles) and type MediaCurrent

    2. Marco Properties > Check (Use in Editor)

    3. And when i insert the macro in my editor, choose the folder in media where the pdf files lies. 

     

    What am i doing wrong??

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 30, 2011 @ 17:00
    Tom Fulton
    0

    That should be it, except if you are using my example you need to change yourParam to pdfFiles, and /Image to /File

    What results are you getting?  Can you post your XSLT?

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 30, 2011 @ 17:12
    Fuji Kusaka
    0

    Its working i had the same page running on another browser!!! Here is the XSLT 

     <xsl:if test="$mediaFolder">
      <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($mediaFolder/*/@id, true())"/>
      
      <xsl:for-each select="$mediaItems/File">
        <li>
          <a href="{umbraco.library:NiceUrl(@id)}" target='_blank'>
            <xsl:value-of select="@nodeName"/>
         </a>
      </li>
      </xsl:for-each>

    </xsl:if>

     

    But am not getting the actual link to download the file.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 30, 2011 @ 17:14
    Tom Fulton
    1

    For the link, you don't need to use NiceURL (actually it doesnt apply to Media), you just get the umbracoFile property:

    <a href="{umbracoFile}" target="_blank">

    As far as the browser issue I'm not sure, try checking what HTML is getting outputted in the source.

    -Tom

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 30, 2011 @ 17:16
    Fuji Kusaka
    0

    Thanks for the Help Tom....

Please Sign in or register to post replies

Write your reply to:

Draft