I want to override the rendering of the built-in ContentType field for lists in display mode. I have read several articles/tutorials on the subject and all agree I should create a custom xsl template and deploy it to LAYOUTS/XSL with a file name in the format fldtypes_*.xsl. A good example being here - http://msdn.microsoft.com/en-us/library/ff606773.aspx
In the fldtypes.xsl containing the built-in templates we can see the one for ContentType looks like this:
<xsl:template name="FieldRef_ContentType_body" ddwrt:dvt_mode="body" match ="FieldRef[@Name='ContentType']" mode="Computed_body"> <xsl:param name="thisNode" select="."/> <xsl:value-of select="$thisNode/@ContentType"/> </xsl:template>
I have made my custom template file as follows:
<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[@Name='ContentType']" mode="Computed_body"> <xsl:param name="thisNode" select="."/> <xsl:value-of select="$thisNode/@ContentType"/> <xsl:value-of select="$thisNode/@ContentType"/> </xsl:template> </xsl:stylesheet>
Note all it actually does is render the name twice for now and is otherwise the same as the built-in template without the name attribute as described in the above linked article.
I have deployed this file to LAYOUTS/XSL with the name fldtypes_ContentType.xsl however after resetting IIS the fields are still rendered using the built-in template contrary to all indications I have found online. Quoting from the above linked MSDN article:
Reset the web application so that the files in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS\XSL are reloaded. Your custom file overrides any of the built-in files.
If I delete the XSL template shown above from the fldtypes.xsl containing the built-in templates and reset IIS my custom template is used and the name renders twice. Replacing the template reverts to the default behaviour.
Obviously it is not acceptable to have to delete something from the fldtypes.xsl file to override this as deployment becomes a real issue then. My question then is why does my template not override the built-in rendering as it would appear it should?