Copied to clipboard

Flag this post as spam?

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


  • Martin 6 posts 26 karma points
    Mar 10, 2011 @ 14:43
    Martin
    0

    URL from Content Picker

    Sorry for this noob question ...

    I am trying to create an xslt macro (GetURLfromContentPicker) that takes the alias of a content picker as a parameter, and returns the URL of that node. My template has:

    <umbraco:Macro ContentPickerAlias="myContentPicker1" Alias="GetURLfromContentPicker" runat="server">

    I have confirmed that my parameter gets passed correctly by outputting:

    <xsl:value-of select="$contentPickerAlias"/>

    So now I want to make the magic happen: Get the node id that this alias contains, and return the URL for that node. I understand that library.niceUrl() is the way to go, but I can't seem to get it right.

    Anyone? :-|

  • Martin 6 posts 26 karma points
    Mar 10, 2011 @ 14:55
    Martin
    0

    I tried to do:

    <xsl:value-of select="umbraco.library:NiceUrl(./data [@alias=$contentPickerAlias])" />

    but it returns a parsing error

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Mar 10, 2011 @ 15:13
    Jeroen Breuer
    0

    Are you using Umbraco 4.5 or higher? In that case try this:

    <xsl:value-of select="umbraco.library:NiceUrl(./name()=$contentPickerAlias)" />

    You could also do this in an Umbraco item without using xslt:

    <a href='<umbraco:Item field="disclaimerLink" runat="server" xslt="umbraco.library:NiceUrl({0})"></umbraco:Item>'>Disclaimer</a>

    Jeroen

  • Mike Chambers 636 posts 1253 karma points c-trib
    Mar 10, 2011 @ 15:14
    Mike Chambers
    0

     

    presume you are doing something like...

    <xsl:variable name="contentPickerAliasselect="/macro/ContentPickerAlias"/>

    and that contentPickerAlias returns a nodeId.

    so all you should heve to do is..

    <xsl:value-of select="umbraco.library:NiceUrl($contentPickerAlias)" />

     

  • Martin 6 posts 26 karma points
    Mar 10, 2011 @ 17:30
    Martin
    0

    Jeroen: I could not get the xslt-example to work. But the error changed from parsing error to "error reading xslt".

    However the inline version worked like a charm!! Thank you so very much!

     

    Mike: Thanks for your tip also! My contentPickerAlias contains the alias of the contentpicker, not the value it is set to (the node id) so I would have to modify this.

  • 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