1

I have edited fldtypes.xsl directly and iisreset. But there seems not changes.

(This is my experimental implementation. I just want to make it clear how the fldtypes.xsl works)

Here is my changes:

Before

  <xsl:otherwise>
    <!-- warning: this code has optimization in webpart. Change it must change the webpart code too!-->
    <a onfocus="OnLink(this)" href="{$thisNode/@FileRef}" onmousedown="return VerifyHref(this,event,'{$XmlDefinition/List/@DefaultItemOpen}','{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/@serverurl.progid}')" 
       onclick="return DispEx(this,event,'TRUE','FALSE','{$thisNode/@File_x0020_Type.url}','{$thisNode/@File_x0020_Type.progid}','{$XmlDefinition/List/@DefaultItemOpen}','{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/@HTML_x0020_File_x0020_Type}','{$thisNode/@serverurl.progid}','{$thisNode/@CheckoutUser.id}','{$Userid}','{$XmlDefinition/List/@ForceCheckout}','{$thisNode/@IsCheckedoutToLocal}','{$thisNode/@PermMask}')">
      <xsl:value-of select="$thisNode/@FileLeafRef.Name" />
    </a>
    <xsl:if test="$thisNode/@Created_x0020_Date.ifnew='1'">
      <xsl:call-template name="NewGif">
        <xsl:with-param name="thisNode" select="$thisNode"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:otherwise>

After

  <xsl:otherwise>
    <!-- warning: this code has optimization in webpart. Change it must change the webpart code too!-->
    <a onfocus="OnLink(this)" href="{$thisNode/@FileRef}" onmousedown="return VerifyHref(this,event,'{$XmlDefinition/List/@DefaultItemOpen}','{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/@serverurl.progid}')" 
       onclick="console.log('15'); return DispEx(this,event,'TRUE','FALSE','{$thisNode/@File_x0020_Type.url}','{$thisNode/@File_x0020_Type.progid}','{$XmlDefinition/List/@DefaultItemOpen}','{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/@HTML_x0020_File_x0020_Type}','{$thisNode/@serverurl.progid}','{$thisNode/@CheckoutUser.id}','{$Userid}','{$XmlDefinition/List/@ForceCheckout}','{$thisNode/@IsCheckedoutToLocal}','{$thisNode/@PermMask}')">
      <xsl:value-of select="$thisNode/@FileLeafRef.Name" />
    </a>
    <xsl:if test="$thisNode/@Created_x0020_Date.ifnew='1'">
      <xsl:call-template name="NewGif">
        <xsl:with-param name="thisNode" select="$thisNode"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:otherwise>
1

This is because of the comment right above the portion you edited: <!-- warning: this code has optimization in webpart. Change it must change the webpart code too!-->.
That exact part of fldtypes.xsl is actually overriden by C# code. You can confirm that by looking (with Reflector, ILSPy, JustDecompile, dotPeek or else) at Microsoft.SharePoint.WebPartPages.WSSXmlUrlResolver.CacheDuplicateDispEx code (in Microsoft.SharePoint.dll):

System.Xml.XmlNode xmlNode3 = this.xmlDocument.SelectSingleNode("/xsl:stylesheet/xsl:template[@name='LinkFilenameNoMenu']", this.mgr);
if (xmlNode3 != null)
{
    System.Xml.XmlNode xmlNode4 = xmlNode3.SelectSingleNode(".//a[not(@href='{$FolderURL}')]");
    if (xmlNode4 != null && xmlNode4.Attributes["onclick"].Value == "return DispEx(this,event,'TRUE','FALSE', <shortened for clarity>")
    {
        **xmlNode4.Attributes["onclick"].Value = "{$thisNode/@ecb.dispex}";**
    }
}
3
  • Thanks, Evariste. Does this mean that when I want to change the behavior of clicking a file in document library, I need to create my own class inheriting CacheDuplicateDispEx? But how? – user48851 Jan 28 '16 at 0:12
  • Ho no, that's way too complicated (impossible). You'd need to re-write a lot of private code, and to connect your new class to the base ones. No, IMO there's no way to by-pass this limitation. Your best option would then probably to inject JavaScript code in page: you'd change the links by jQuery or else on each page-load, client-side. Dirty but less dirty than re-writing the impossible. – Evariste Jan 28 '16 at 6:17
  • Thanks a lot. I found that fldtypes.xsl is not standard way to customize view rendering, and JSLink takes the place in 2013. I decide to use JSLink and it works fine (but it requires a bit work with clienttemplates.js) – user48851 Feb 1 '16 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy