Question

I have a custom XSL transform for a Text column and it works fine. Here is markup:

 <xsl:template name="FieldRef_Text_body" ddwrt:dvt_mode="body" match ="FieldRef" mode="Text_body">
    <xsl:param name="thisNode" select="."/>
    <xsl:param name="field" />
    <xsl:variable name="value">
      <xsl:choose>
        <xsl:when test="@AutoHyperLink='TRUE'">
          <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$thisNode/@*[name()=current()/@Name]"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$field = 'Title' and $thisNode/@FileLeafRef.Suffix != '000'">
        <a href="{$thisNode/@FileRef}" class="lanit-title-docs">
          <xsl:choose>
            <xsl:when test="string-length($value) &gt; 0">
              <xsl:value-of select="$value" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$thisNode/@FileLeafRef.Name" />
            </xsl:otherwise>
          </xsl:choose>
        </a>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$value" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

This markup add file download url for every title column on site. Now I want to write similar code for my own field, but he's of type Note.

I write this test code but it always use default realisation:

  <xsl:template match="FieldRef[@Name='PublicDocument_FullName']" mode="body">
    <xsl:param name="thisNode" select="."/>
    <div dir="{@Direction}" class="ms-rtestate-field">
      <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes"/>
      <a href="#">FieldRef Custom1 First</a>
    </div>
  </xsl:template>
  <xsl:template name="FieldRef_Note_body" ddwrt:dvt_mode="body" match="FieldRef" mode="Note_body">
    <xsl:param name="thisNode" select="."/>
    <div dir="{@Direction}" class="ms-rtestate-field">
      <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes"/>
      <a href="#">FieldRef Default</a>
    </div>
  </xsl:template>
  <xsl:template match="FieldRef[@Name='PublicDocument_FullName']" mode="body">
    <xsl:param name="thisNode" select="."/>
    <div dir="{@Direction}" class="ms-rtestate-field">
      <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes"/>
      <a href="#">FieldRef Custom2 Second</a>
    </div>
  </xsl:template>

I need that node contains URL for file download, but it doesn't even renders proper template.

enter image description here

And when I remove default node it just doesn't render anything. match="FieldRef[@ID='C0069E1C-A7AE-4522-BAC3-BC69244D2CB1']" is not working too.

  1. How can I render proper template?
  2. How can I get access to @FileLeafRef.Name?

Here is field declaration:

  <Field ID="{C0069E1C-A7AE-4522-BAC3-BC69244D2CB1}" 
         Name="PublicDocument_FullName"
         StaticName="PublicDocument_FullName"
         DisplayName="$Resources:Inv, Field_PublicDocument_FullName;"
         Group="$Resources:Inv, Field_PublicDocument_Group;"
         Type="Note"
         UnlimitedLengthInDocumentLibrary="TRUE"
         Required="FALSE" />
Was it helpful?

Solution

This markup worked for me.

  <xsl:template name="FieldRef_Note_body_PublicDocument_FullName" ddwrt:dvt_mode="body" match="FieldRef[@Name='PublicDocument_FullName']" mode="Note_body">
    <xsl:param name="thisNode" select="."/>
    <a href="{$thisNode/@FileRef}" class="lanit-title-docs">
      <div dir="{@Direction}" class="ms-rtestate-field">
        <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes"/>
      </div>
    </a>
  </xsl:template>

I hope it will be helpful for somebody.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top