Custom field type XSL in SP2010

jason.venema
  • Custom field type XSL in SP2010 jason.venema

    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>
    

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

Tags
xslt custom-field-types caml-renderpattern
Related questions and answers
  • uses a DataFormWebPart which contains xsl stylesheet. It has a 'Complete Task' button as below: &lt;td>&lt;input type="button" name="btnMarkSubmited" value="Complete Task" onclick="javascript: {ddwrt...;xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http...://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal"&gt; &lt;xsl:output method="html" indent

  • I have this (an attempt to solve the task): &lt;xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes..."/&gt; &lt;xsl:value-of select="sum($Rows/@Distance[.!=''])" /&gt; &lt;/xsl:template> &lt;/xsl:stylesheet> The result is: "NaN", so I figure that my XSLT is wrong. Question.../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

  • . Then I've added each content type to the Tasks list. After that I've added each lookup site column to the corresponding list content type. So far so good. I've built a custom WebPart that displays task items...' /&gt; &lt;Value Type='Lookup'&gt;1&lt;/Value> &lt;/Eq> &lt;/Where> &lt;/Query> The problem is that this SPQuery returns results only for the first 13 lookup columns. If I put in the FieldRef the internal name for lookup column no 14 or above, it is not working anymore. Why? If I don't use LookupId='TRUE' and do this: (use the value of the lookup

  • ; &lt;Case Value = "1"&gt; &lt;HTML> &lt;![CDATA[A new content has been added to Latest Events. To view, please visit: &lt;a href...="EventType" /&gt; &lt;/Expr> &lt;Case Value = "1"&gt; &lt;HTML>New Content on Latest Events</HTML> &lt;/Case> &lt;Case Value = "2"&gt... Name = "ItemName" /&gt; &lt;HTML>&lt;![CDATA[&lt;/a>;&lt;br/&gt;Thank You<br/&gt;]]&gt;&lt;/HTML> &lt;/Case> &lt;Case Value = "2"&gt

  • xmlns="http://schemas.microsoft.com/sharepoint/" &gt; &lt;Module Name="IdeaGrid" List="113" Url="_catalogs/wp"&gt; &lt;File Path="IdeaGrid\IdeaGrid.webpart" Url="IdeaGrid.webpart" Type...="http://schemas.microsoft.com/sharepoint/" &gt; &lt;Module Name="Home" List="113" Url="_catalogs/wp"&gt; &lt;File Path="Home\Home.webpart" Url="Home.webpart" Type="GhostableInLibrary" &gt; &lt;Property Name="Group" Value="Custom" /&gt; &lt;/File> &lt;/Module> &lt;/Elements> IdeaEditor elements.xml &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Elements xmlns="http

  • I have a content type defined in Elements.xml and I want to add an Event Receiver. My Elements.xml looks like this: &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Elements xmlns="http...="" ShowInNewForm="TRUE" ShowInEditForm="TRUE" /&gt; &lt;Field ID="{7662cd2c-f069-4dba-9e35-082cf976e170}" Name="Body" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Body" Group...://schemas.microsoft.com/sharepoint/events"&gt; &lt;spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events"&gt; &lt;Receiver> &lt;Name>ItemAdded</Name>

  • ; &lt;FieldRef Name="ID" /&gt; &lt;!-- Field which do not return values --&gt; &lt;FieldRef Name="Responsible" Nullable="TRUE" Type="UserMulti" /&gt; &lt;FieldRef Name="Accountable" Nullable="TRUE" Type="UserMulti" /&gt; &lt;!-- // Field which do not return values --&gt; &lt;ProjectProperty Name="Title" /&gt; &lt;/ViewFields> &lt;/View> &lt;Query>... to access "Accountable". &lt;xsl:value-of select="@Accountable" /&gt; I've seen a few posts that indicate that this was a problem pre-SP2 however my farm is already running SP2 with the August CU

  • xmlns:ows="Microsoft SharePoint" Title="Withdrawals" FolderCreation="FALSE" Direction="LTR" Url="Lists/Withdrawals" EnableContentTypes="TRUE" BaseType="0"&gt; &lt;MetaData> &lt;ContentTypes>...://schemas.microsoft.com/sharepoint/v3/contenttype/forms"&gt; &lt;FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms"&gt; &lt;Display>ListForm</Display> &lt...="{CE8F7528-E643-4473-94E0-BAA57BD2F6E6}" Name="TeamName" StaticName="TeamName" DisplayName="Team Name" Type="Text"&gt; &lt;/Field> &lt;Field ID="{E508D1FA-D3A5-4e91-828B-3BFB43D4F7C5}" Name

  • In a custom list there is a column / field defined as “Name (with presence)”. In my modified aspx page, I want to do an ‘xsl if’ statement to check if the value from this field is the same as the current user. &lt;xsl:if test="@MyField = $UserID"&gt; ... code here ... &lt;/xsl:if> But the compare fails because the content from the MyField is something like : &lt;span> &lt;A HREF="/sites/121579/MySite/_layouts/userdisp.aspx?ID=452"&gt;***, Stef</A>; &lt;img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/&gt; &lt;a href

Data information