Return to doc.sitecore.com

Valid for Sitecore 5.3.1
16.  Reference, Tree and Lookup
Prev Next

The value of the Reference, Tree and Lookup fields is the ID of the referenced item. Using the ID you can retrieve the item itself and process it according to the needs of your application.

<xsl:variable name="my_id" select="sc:fld( 'My Reference', . )"/>

<!-- true if the field has been populated -->

<xsl:if test="$my_id">

  <!-- retrieve the item corresponding to this GUID -->

  <xsl:variable name="my_item" select="sc:item( $my_id, . )" />

  <!-- true if the GUID maps to an item which currently exists -->

  <xsl:if test="$my_item">

    <!-- retrieve an attribute of the referenced item -->

    <xsl:value-of select="$my_item/@name" />

    <!-- retrieve a field value from the referenced item -->

    <sc:text field="my_text_field" select="$my_item" />

  </xsl:if>

</xsl:if>


Prev Next