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!
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.
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 :)
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?
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.
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
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
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!
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 :)
Let me know if that does the trick. Note this is for a media picker.
-Tom
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 > 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
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
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
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
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
Ah maybe not im just being impatient! does load in browser just takes a while (obviously!)
Cheers mate your a star
Don't suppose your a XSLT - SQL man are you heh heh
is working on a reply...