You need to wrap the NiceUrl around a test to ensure $chosenPage has a value, otherwise it may not when you save the file and umbraco does it's testing (just like you do with GetMedia.
<xsl:iftest="$chosenPage > 0"> .... </xsl:if>
Also not sure if you meant to or not but it looks like you're using the old schema on that variable ;)
No wasnt meant to be using the old schema. I still didnt get it to work. I forgot to mention that i added a new Property in my Image Media Content with type contentPicker to enable user to add a link to the image upload from the media section itself.
I know it might sound weird but the client wanted to be able to get each image a specific url to the content of the website itself.
Are you getting the same error? The above should really fix that error.
But also, is your content picker value (urlBanner) coming from the media item itself? If so you can eliminate the $chosenPage and just get it from your media varaible
<xsl:template match="/"> <!-- start writing XSLT --> <xsl:if test="number($BannerImage)"> <xsl:for-each select="umbraco.library:GetMedia($BannerImage, 'true')/Image"> <xsl:variable name="chosenPage" select="./urlBanner"/> <!-- Grab the content picker value from the Image --> <xsl:if test="$chosenPage > 0"> <!-- Only show the below if a value was selected in the content picker. You could move this around if you want other behavior, but it needs to wrap the NiceUrl in case the value is empty --> <li> <a href="{umbraco.library:NiceUrl($chosenPage)}"> <xsl:element name="img"> <xsl:attribute name="src"> <xsl:value-of select="umbracoFile"/> </xsl:attribute> </xsl:element> </a> </li> </xsl:if> </xsl:for-each> </xsl:if> </xsl:template>
Converting Id to NiceUrl
Hi All,
I have an issue here where i need to convert an Id from my ContentPicker to a NiceUrl.
Cant save the file getting Error Value was either too large or too small for an Int32
//fuji
Hi fuji,
You need to wrap the NiceUrl around a test to ensure $chosenPage has a value, otherwise it may not when you save the file and umbraco does it's testing (just like you do with GetMedia.
Also not sure if you meant to or not but it looks like you're using the old schema on that variable ;)
-Tom
Hi Tom,
No wasnt meant to be using the old schema. I still didnt get it to work. I forgot to mention that i added a new Property in my Image Media Content with type contentPicker to enable user to add a link to the image upload from the media section itself.
I know it might sound weird but the client wanted to be able to get each image a specific url to the content of the website itself.
Hi Fuji,
Are you getting the same error? The above should really fix that error.
But also, is your content picker value (urlBanner) coming from the media item itself? If so you can eliminate the $chosenPage and just get it from your media varaible
-Tom
Hi Tom,
Thanks for the response. Well i didnt changed the variable, so wasnt getting any results.
//fuji
is working on a reply...