Display URL field in Content Query Web Part

15/11/2012 10:23

URL field is sending from Content Query Web Part (via CommonViewFields property). We want to display it as it is in a list, description text with link.

We have to split Url value which is sent as: url, description. That's why it's parsed to variables.

 

<xsl:stylesheet
  version="1.0"
  exclude-result-prefixes="x d xsl msxsl cmswrt"
  xmlns:x="https://www.w3.org/2001/XMLSchema"
  xmlns:d="https://schemas.microsoft.com/sharepoint/dsp"
  xmlns:cmswrt="https://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
  xmlns:xsl="https://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">

  <xsl:param name="ItemsHaveStreams">
    <xsl:value-of select="'False'" />
  </xsl:param>


  <xsl:template name="Default" match="*" mode="itemstyle">
    <xsl:variable name="UrlLink" select='substring-before(@URL, ",")'></xsl:variable>
    <xsl:variable name="UrlDescription" select='substring-after(@URL, ", ")'></xsl:variable>
    <div class="item link-item customClass">
        <a href="{$UrlLink}">
          <xsl:value-of disable-output-escaping="yes" select="$UrlDescription"/>
        </a>
    </div>
  </xsl:template>
</xsl:stylesheet>