Copied to clipboard

Flag this post as spam?

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


  • Rachel Skuse 88 posts 118 karma points
    Feb 16, 2010 @ 18:38
    Rachel Skuse
    0

    Get URL of content picker

    Hi,

    If

     umbraco.library:NiceUrl(@id) 

    gets the url of the current page, how do I get the url that I have just picked in a content picker where the alias is 'testlink' for example?

    I've tried along the lines of

    umbraco.library:NiceUrl($currentpage/[@alias='testLink'])

    but I just get an error when saving the xslt file.

    Thanks,
    Rachel

     

  • dandrayne 1138 posts 2262 karma points
    Feb 16, 2010 @ 19:58
    dandrayne
    2

    Hi Rachel

    $currentPage has a capital P, so this will probably be causing you issues.  For posterity, here's what I use (a bit more verbose though)

    umbraco.library:NiceUrl($currentPage/data[@alias='testLink'])

    Hope this helps,
    Dan

  • Rachel Skuse 88 posts 118 karma points
    Feb 17, 2010 @ 09:55
    Rachel Skuse
    0

    Thanks Dan.

    I want to check if 'hobOptions' has a url associated with it (from a content picker) and, if it has, display an image with a link from 'hobOption'

    I'm trying to do something like the following...

    <xsl:if test="string($currentPage/data[@alias='hobOptions']) != ''">
            <xsl:variable name="url" select="umbraco.library:NiceUrl($currentPage/data[@alias='hobOptions'], 0)"/>
                    <li>
                            <a href="{$url}"><img src="/media/53/hob_options.jpg" /></a>
                    </li>

    </xsl:if>

     but I'm getting an error on my page "Error parsing XSLT file: \xslt\ProductOptions.xslt"

    So I think I'm missing something but i'm not sure what!

    Thanks,

    Rachel

     

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 17, 2010 @ 10:03
    Kim Andersen
    1

    Hi Rachel

    You could try this one out:

    <xsl:if test="$currentPage/data[@alias='hobOptions'] != ''">
           
    <xsl:variable name="url" select="umbraco.library:NiceUrl($currentPage/data[@alias='hobOptions'])"/>
           
    <li>
                   
    <a href="{$url}"><img src="/media/53/hob_options.jpg" /></a>
           
    </li>
    </xsl:if>

    This should work. You shouldn't use the last ", 0" in the umbraco.library:NiceUrl.

    Hope this works :)

    /Kim A

  • Rachel Skuse 88 posts 118 karma points
    Feb 17, 2010 @ 10:14
    Rachel Skuse
    0

    Thanks Kim, works like a charm!

    I was confused as previously I had been trying to do a similar thing with GetMedia.

    Thanks for your help.

    Rachel

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 17, 2010 @ 10:27
    Kim Andersen
    0

    Good to hear Rachel. Glad I could help...

    /Kim A

  • 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