I've created an image gallery slideshow. Each image is wrapped in a <a href> tag to link to the corresponding project. The user uploads the image then using the custom content picker "projectLink" pick which page they need to link to. This is working, however the URL displaying the node number, not the full URL name.
I've tried adding the NiceUrl code to the link but this causes errors and doesn't work. I'm using 4.5. Any suggestions?
<!-- a little hack to work around the xslt syntax checker when opening/closing UL lists in two separate IF statements --> <!-- if it weren't for IE we could use a single UL and simply float the LI's and they'd auto-wrap --> <!-- but for IE we either need separate UL rows or else we need to hard-code the LI's height in CSS --> <!-- this approach with separate UL rows works in all browsers and row heights --> <xsl:variable name="ulOpen"><xsl:text><ul id="slider1"></xsl:text></xsl:variable> <xsl:variable name="ulClose"><xsl:text></ul></xsl:text></xsl:variable>
<xsl:for-each select="$currentPage/* [@isDoc][string(umbracoNaviHide) != '1']"> <!-- open a row of images --> <xsl:if test="position() = 1 or position() mod $imagesPerRow = 0"> <xsl:value-of select="$ulOpen" disable-output-escaping="yes" /> </xsl:if>
<!-- display each image in the row, with the count of photos in each gallery --> <li> <a href="{projectLink}" title="{projectLink}"> <xsl:if test="homeImage != ''"> <img alt=""> <xsl:attribute name="src"> <xsl:value-of select="homeImage" /> </xsl:attribute> </img> </xsl:if> </a> </li>
<!-- close the row of images --> <xsl:if test="position() = ($imagesPerRow - 1) or position() mod ($imagesPerRow - 1) = 0 or position() = last()"> <xsl:value-of select="$ulClose" disable-output-escaping="yes"/> </xsl:if> </xsl:for-each>
<!-- display each image in the row, with the count of photos in each gallery -->
<li>
<a href="{umbraco.library:NiceUrl(projectLink)}" title="{umbraco.library:GetXmlNodeById(projectLink)/@nodeName}">
<xsl:if test="homeImage != ''">
<img alt="">
<xsl:attribute name="src">
<xsl:value-of select="homeImage" />
</xsl:attribute>
</img>
</xsl:if>
</a>
</li>
<!-- a little hack to work around the xslt syntax checker when opening/closing UL lists in two separate IF statements --> <!-- if it weren't for IE we could use a single UL and simply float the LI's and they'd auto-wrap --> <!-- but for IE we either need separate UL rows or else we need to hard-code the LI's height in CSS --> <!-- this approach with separate UL rows works in all browsers and row heights --> <xsl:variable name="ulOpen"><xsl:text><ul id="slider1"></xsl:text></xsl:variable> <xsl:variable name="ulClose"><xsl:text></ul></xsl:text></xsl:variable>
<xsl:for-each select="$currentPage/* [@isDoc][string(umbracoNaviHide) != '1']"> <!-- open a row of images --> <xsl:if test="position() = 1 or position() mod $imagesPerRow = 0"> <xsl:value-of select="$ulOpen" disable-output-escaping="yes" /> </xsl:if>
<!-- display each image in the row, with the count of photos in each gallery --> <xsl:if test="string(projectLink) != ''"> <li> <a href="{umbraco.library:NiceUrl(projectLink)}" title="{umbraco.library:GetXmlNodeById(projectLink)/@nodeName}"> <xsl:if test="homeImage != ''"> <img alt=""> <xsl:attribute name="src"> <xsl:value-of select="homeImage" /> </xsl:attribute> </img> </xsl:if> </a> </li> </xsl:if>
<!-- close the row of images --> <xsl:if test="position() = ($imagesPerRow - 1) or position() mod ($imagesPerRow - 1) = 0 or position() = last()"> <xsl:value-of select="$ulClose" disable-output-escaping="yes"/> </xsl:if> </xsl:for-each>
Content picker NiceUrl
I've created an image gallery slideshow. Each image is wrapped in a <a href> tag to link to the corresponding project. The user uploads the image then using the custom content picker "projectLink" pick which page they need to link to. This is working, however the URL displaying the node number, not the full URL name.
I've tried adding the NiceUrl code to the link but this causes errors and doesn't work. I'm using 4.5.
Any suggestions?
Hey JV,
Try this
Rich
Hi Rich,
I've tried that, keeps throwing the following error:
Error occured
System.OverflowException: Value was either too large or too small for an Int32.
JV
Hi JV
You need to wrap the NiceUrl in an if statement to ensure projectLink has a value (it won't during the save-test)
Thanks Tom! You've saved me again.
Here's my final code:
is working on a reply...