I'm having a issue with trying to create a NiceURL in my XSLT when picking a link using contentPicker.
I know to how to create the NiceURL in the XSLT: href="{umbraco.library:NiceUrl(1050)}" but I want to get the value of the contentPicker and place it into my NiceURL.
I have tried decalring it as a variable, placing a value-of within the brackets but just getting errors.
Generating NiceURL from ContentPicker value
Hi All,
I'm having a issue with trying to create a NiceURL in my XSLT when picking a link using contentPicker.
I know to how to create the NiceURL in the XSLT: href="{umbraco.library:NiceUrl(1050)}" but I want to get the value of the contentPicker and place it into my NiceURL.
I have tried decalring it as a variable, placing a value-of within the brackets but just getting errors.
Any help greatly appreciated.
Tom
As far as I can remember, the value stored by the content picker is simply the ID of the picked node?
(untested!)
Dan,
I tried that earlier but was just getting an error:
"Value was either too large or too small for an Int32"
Tom
Comment author was deleted
Hi Tom,
To avoid the error, wrap the niceurl call inside a xsl:if, to make sure there is a value
like:
<xsl:if test="string-length($currentPage/data[@alias='YourContentPickerAlias']) > 0">
<a href="{umbraco.library:NiceUrl($currentPage/data[@alias='YourContentPickerAlias'])}">link</a>
</xsl:if>
Cheers Tim.
That worked perfectly!!
Using Umbraco 4.5.1 and not getting this to work, causes an error. Also, how do I get the title of the link?
umbraco v4.5.1 has a new xml schema, check this wiki page http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema
is working on a reply...