Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Maton 387 posts 660 karma points
    Jul 21, 2009 @ 12:18
    Tom Maton
    0

    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

  • dandrayne 1138 posts 2262 karma points
    Jul 21, 2009 @ 12:29
    dandrayne
    0

    As far as I can remember, the value stored by the content picker is simply the ID of the picked node?

    <xsl:variable name="chosenPage" select="$currentPage/data[@alias='YourContentPickerAlias']"/>
    <a href="{umbraco.library:NiceUrl($chosenPage)}">link</a>

    (untested!)

  • Tom Maton 387 posts 660 karma points
    Jul 21, 2009 @ 13:23
    Tom Maton
    0

    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

    Jul 21, 2009 @ 13:33

    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']) &gt; 0">
    <a href="{umbraco.library:NiceUrl($currentPage/data[@alias='YourContentPickerAlias'])}">link</a>
    </xsl:if>

  • Tom Maton 387 posts 660 karma points
    Jul 21, 2009 @ 15:15
    Tom Maton
    0

    Cheers Tim.

    That worked perfectly!!

  • Connie DeCinko 931 posts 1160 karma points
    Jul 26, 2010 @ 18:38
    Connie DeCinko
    0

    Using Umbraco 4.5.1 and not getting this to work, causes an error.  Also, how do I get the title of the link?

  • Julius Bartkus 51 posts 76 karma points
    Jul 27, 2010 @ 23:23
    Julius Bartkus
    0
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies