Copied to clipboard

Flag this post as spam?

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


  • Brian Andersen 35 posts 66 karma points
    Nov 10, 2010 @ 20:17
    Brian Andersen
    0

    Use Content Picker in XSLT for links

    Small question, I could not find the answer.. What is the syntax for using the content picker for a link in the new scheme:

    I got my contentpicker content and now i want to use it in my XSLT like this:  <a href="link taken from umbraco" />

    How is it done? Do i use  <xsl:attribute ? 

    Thanks
    Brian

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Nov 10, 2010 @ 20:25
    Chriztian Steinmeier
    1

    Hi Brian,

    You just send the contents to NiceUrl() - e.g., like this:

    <a href="{umbraco.library:NiceUrl($currentPage/PICKER_ALIAS_HERE)}">Link text</a>
    

    /Chriztian

  • Brian Andersen 35 posts 66 karma points
    Nov 10, 2010 @ 20:25
    Brian Andersen
    0

    Found the answer allready. Hope someone else can use it.

    Like this:
      <a href="{umbraco.library:NiceUrl($node/contentPickerName)}">


  • Brian Andersen 35 posts 66 karma points
    Nov 10, 2010 @ 20:26
    Brian Andersen
    0

    Ah sorry Chriztian but thinks anyway :-)

  • Rich Green 2246 posts 4008 karma points
    Nov 10, 2010 @ 20:26
    Rich Green
    0

    This should work for you

    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>

    Basically the content picker returns an id, so NiceUrl returns the path

    Rich

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Nov 10, 2010 @ 20:29
    Chriztian Steinmeier
    0

    Here's a little more to get you going, which also makes sure not to call NiceUrl() if no node was picked (throws nasty Int32 error if not):

    <xsl:template match="/">
    
        <!-- some output -->
    
        <!-- output link here, if there was a node picked: -->
        <xsl:apply-templates select="$currentPage/PICKER_ALIAS[normalize-space()]" />
    
        <!-- some more output -->
    
    </xsl:template>
    
    <!-- Template for link -->
    <xsl:template match="PICKER_ALIAS_HERE">
        <a href="{umbraco.library:NiceUrl(.)}">Link text</a>
    </xsl:template>

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft