I just noticed that in the code the test statement is testing for a different element to the href is looking at. Was the original code meant to be like that?
If it's a media picker, you need to use the GetMedia-extension to get the filename of the file that you want to link to, and if you are linking to a page in the content tree, you can use the NiceUrl-extension.
If you just want to link to a pdf-file that the users can download, I'd suggest that you upload those pdf-files to the media library, and then chooses the files from a mediapicker on your subpages.
Then you can use the first snippet I provided above to render the link to the files.
If you are usig the other method with NiceUrl, you'll get a link sending the users to a different page in the content tree. But of course it's all up to you :)
Nice URL 4.5 error
Hi, guys!
I am quite new top umbraco and I have have a problem with a url to file that its uploaded and pointed out with a content picker. I get the error:
Value was either too large or too small for an Int32.
The code looks like this:
<xsl:for-each select="$currentPage/*[@isDoc and string(umbracoNaviHide) != '1']">
<xsl:if test="current()/supplier_avtalstyp != ''">
<a href="{umbraco.library:NiceUrl($currentPage/supplier_avtalsfil)}">Avtal</a>
</xsl:if>
Is there anyone who can help me?
// Nicklas
You're passing in the XmlNode to NiceUrl, not the ID of the page, try this:
Thanks, but it doesn´t help. Same error....
I just noticed that in the code the test statement is testing for a different element to the href is looking at. Was the original code meant to be like that?
The code look like this.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour" xmlns:UCommentLibrary="urn:UCommentLibrary"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour UCommentLibrary ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="documentTypeAlias" select="string('Leverantor')"/>
<xsl:template match="/">
<!-- The fun starts here -->
<table width="500">
<xsl:for-each select="$currentPage/*[@isDoc and string(umbracoNaviHide) != '1']">
<tr>
<td>
- <a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</td>
<td>
<xsl:if test="current()/supplier_prio != ''">
<xsl:variable name="bild" select="umbraco.library:GetMedia(current()/supplier_prio, 'false')" />
<img src="{$bild/umbracoFile}" />
</xsl:if>
</td>
<td>
<xsl:if test="current()/supplier_avtalstyp != ''">
<a href="{umbraco.library:NiceUrl($currentPage/supplier_avtalsfil/@id)}">Avtal</a>
</xsl:if>
</td>
<td>
<xsl:if test="current()/supplier_info!= ''">
Information
</xsl:if>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Hi Nicklas
Where's the property called supplier_avtalsfil placed? On the current page or on the subpages that you are iteration through?
/Kim A
The property supplier_avtalsfil is a content picker located on the subpage.
The content picker point on a pdf-file thats uploaded into content tree.
Yeah there's a test happening against supplier_avtalalsfil but then reading out of something else, not using it on the next line anyway
Could you try this if you are using a media picker for the supplier_avtalsfil:
And this if you are using a content picker:
If it's a media picker, you need to use the GetMedia-extension to get the filename of the file that you want to link to, and if you are linking to a page in the content tree, you can use the NiceUrl-extension.
Does any of the above code work for you?
/Kim A
Yes! That code for content picker worked!!!
Thanks guys!!
Now I´ve just have to figure out how to show the file, beacuse now it´s just a blank page! ;=)
Glad it worked Nicklas.
If you just want to link to a pdf-file that the users can download, I'd suggest that you upload those pdf-files to the media library, and then chooses the files from a mediapicker on your subpages.
Then you can use the first snippet I provided above to render the link to the files.
If you are usig the other method with NiceUrl, you'll get a link sending the users to a different page in the content tree. But of course it's all up to you :)
/Kim A
But I want the pdf file to be protected with a login. So I use the Public Access function to control this.
Can I in the template for the page with the pdf -file call the url to file so the user wont need to click on a link?
is working on a reply...