Copied to clipboard

Flag this post as spam?

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


  • Haris 12 posts 32 karma points
    Jun 09, 2011 @ 02:46
    Haris
    0

    Picked content url

    Hi all,

    I have a content picker in my document type, and I want to retrieve the "Link to document" property of the picked content in XSLT.  Is this possible? If yes, how?

     

    Thanks

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 09, 2011 @ 03:48
    Tom Fulton
    0

    Hi,

    There's a function built into umbraco.library called NiceUrl that you can use to get a page's URL from it's ID (which the Content Picker stores).

    Ex:

    <xsl:if test="$currentPage/yourContentPickerPropertyAlias != ''">
      <a href="{umbraco.library:NiceUrl($currentPage/yourContentPickerPropertyAlias)}">Link text</a>
    </xsl:if>

    If you want to retrieve other properties from the picked page, like it's name, you can use GetXmlNodeById:

    <xsl:if test="$currentPage/yourContentPickerPropertyAlias != ''">
      <xsl:variable name="pickedPage" select="umbraco.library:GetXmlNodeById($currentPage/yourContentPickerPropertyAlias)"/>
        <a href="{umbraco.library:NiceUrl($pickedPage/@id)}">
          <xsl:value-of select="$pickedPage/@nodeName"/>
        </a>
    </xsl:if>

    Hope this helps,
    Tom

Please Sign in or register to post replies

Write your reply to:

Draft