Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Has anybody upgraded an old custom field type to use the new XSL transform in SharePoint 2010? I have a multi-column field type, and want the Display pattern to render the 2nd "column", which contains a hyperlink. My CAML render pattern looks like:

<RenderPattern Name="DisplayPattern">
   <Switch>
      <Expr>
         <Column />
      </Expr>
      <Case Value="" />
      <Default>
         <HTML><![CDATA[<a href=']]></HTML>
         <Column SubColumnNumber="1" HTMLEncode="TRUE" />
         <HTML><![CDATA['>]]></HTML>
         <Column SubColumnNumber="1" HTMLEncode="TRUE" />
         <HTML><![CDATA[</a>]]></HTML>
      </Default>
   </Switch>
</RenderPattern>

In WSS 3.0, this would render the 2nd column in the field as a hyperlink in the LVWP, which is what I want. In SharePoint 2010, I tried adding TRUE to my field type definition, but that ends up rendering the actual anchor tag, as opposed to a clickable hyperlink:

<a href="http://www.something.com">www.something.com</a>

So then I tried creating a XSL transform, since that is supposed to be the new and improved way of doing this. Unfortunately, I can't get that to work either. I am getting the same thing I got using the RenderPattern. I'm no XSL expert, so can anyone confirm (or deny) that the following looks legitimate (or suggest a better way to do it)?

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">

  <xsl:template match="FieldRef[@FieldType='DataLinkUrl']" mode="Note_body">
    <xsl:param name="thisNode" select="."/>
    <xsl:variable name="url">
      <xsl:value-of select="substring-before(substring-after(substring-after($thisNode/@*[name()=current()/@Name],';#'),';#'),';#')"/>
    </xsl:variable>
    <a href="{$url}"><xsl:value-of select="$url"/></a>
  </xsl:template>

</xsl:stylesheet>
share|improve this question
add comment

1 Answer

This link will help you to understand how mode attribute value is calculated.

share|improve this answer
1  
Thanks, that was helpful in confirming what I already had for the "mode" attribute. In case anyone is interested in the future, I ended up using the ddwrt:HtmlDecode function to get my URL properly decoded: <xsl:variable name="link"> <xsl:value-of disable-output-escaping="yes" select="substring-after(ddwrt:HtmlDecode($thisNode/@*[name()=current()/@Name]),'‌​,')" /> </xsl:variable> <a href="{substring-before(substring-after($link,'href=&quot;'),', ')}">Link</a> –  jason.venema Sep 20 '10 at 16:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.