Copied to clipboard

Flag this post as spam?

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


  • Peter Alcock 113 posts 176 karma points
    Mar 15, 2012 @ 15:00
    Peter Alcock
    0

    Download PDF link

    Hi all hoping for some help!

    Im trying to create a download link to a PDF stored in the media section. Ie tried several different options found on the forums but none seem to work im either getting

    System.OverflowException: Value was either too large or too small for an Int32.

    Or just nothing displayed, have tried using a simple link to document from a RTE, upload datatype, media picker but had no joy! I would prefer the Media picker method if possible!

    <a>
      <xsl:attribute name="href">    
         <xsl:value-of select="umbraco.library:GetMedia($currentPage/menuDownload, 0)/umbracoFile"/>  
        </xsl:attribute>
       <xsl:attribute name="target">
        <xsl:value-of select="'_blank'" />
        </xsl:attribute>
      </a>

    This is the code ive found which people are saying works but still getting the above error, if i wrap it in an IF i dont get an error but nothing displays on the page.

    Running V 4.7


    Thanks

  • bob baty-barr 1180 posts 1294 karma points MVP
    Mar 15, 2012 @ 15:57
    bob baty-barr
    0

    what do you get if you just put on your xslt above your a tag...

    <xsl:value-of select="$currentPage/menuDownload"/>

    assuming we are using a media picker, we are looking for a nodeID from the media item

    let me know... we will get this figured out!

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 15, 2012 @ 15:58
    Tom Fulton
    0

    Hi,

    As you mentioned you should wrap the block in an IF statement to ensure that menuDownload has a media chosen.  If it doesn't, it will get an error when it runs.  If you did this and nothing showed up menuDownload was probably blank :)

    <xsl:if test="$currentPage/menuDownload &gt; 0"> 
    <a>
      <xsl:attribute name="href">    
         <xsl:value-of select="umbraco.library:GetMedia($currentPage/menuDownload, 0)/umbracoFile"/>  
        </xsl:attribute>
       <xsl:attribute name="target">
        <xsl:value-of select="'_blank'" />
        </xsl:attribute>
      </a>
    </xsl:if> 

    Let me know if that does the trick.  Note this is for a media picker.

    -Tom

  • Peter Alcock 113 posts 176 karma points
    Mar 15, 2012 @ 16:09
    Peter Alcock
    0

    Hiya,

    Thanks for the quick responses, just tried using your code Tom which got me excited as didn't error straight away! so i have

    <xsl:if test="$currentPage/menuDownload &gt; 0">
     <a>
      <xsl:attribute name="href">    
         <xsl:value-of select="umbraco.library:GetMedia($currentPage/menuDownload, 0)/umbracoFile"/>  
        </xsl:attribute>
       <xsl:attribute name="target">
        <xsl:value-of select="'_blank'" />
        </xsl:attribute>
       Click Here
      </a>
    </xsl:if>

    But when i click on the link it's just opening a new blank browser window (Url is of the correct file etc) when i would expect it to ask to open or save?

    Thanks again

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 15, 2012 @ 16:11
    Tom Fulton
    0

    Glad it worked!

    Is it opening a blank window or a window with the PDF loaded inside the browser?  The open/save dialog is dependent upon the browser/computer - to force the dialog it you'd need to use some .NET code, otherwise it should just load embedded in the browser.

    -Tom

  • Peter Alcock 113 posts 176 karma points
    Mar 15, 2012 @ 16:13
    Peter Alcock
    0

    Hi Tom,

    It is just a blank white page with no content unfortunatly, I see what you mean opening it in the browser window would be good enough for me!

    Thanks

  • Peter Alcock 113 posts 176 karma points
    Mar 15, 2012 @ 16:13
    Peter Alcock
    0

    Hi Tom,

    It is just a blank white page with no content unfortunatly, I see what you mean opening it in the browser window would be good enough for me!

    Thanks

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 15, 2012 @ 16:14
    Tom Fulton
    0

    That's odd, but the URL is correct?  What happens if you copy/paste the URL into a new browser window?  Have you tried another browser?  Can't think it's anything to do w/Umbraco

  • Peter Alcock 113 posts 176 karma points
    Mar 15, 2012 @ 16:14
    Peter Alcock
    0

    Ah maybe not im just being impatient! does load in browser just takes a while (obviously!)

    Cheers mate your a star

  • Peter Alcock 113 posts 176 karma points
    Mar 15, 2012 @ 16:18
    Peter Alcock
    0

    Don't suppose your a XSLT - SQL man are you heh heh

Please Sign in or register to post replies

Write your reply to:

Draft