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

I'm trying to modify the out-of-the-box rendering of the xslt list view webpart to collapse the terms, and show (..more) if there are more than 1 term in the field. I already did this for an "Authors" field (user field), which shows a pop-up for the rest of the users using jQuery.

Maybe the pic will tell you more. http://i.imgur.com/mWpS4.png (can't post images)

Now, I'm trying to do the same for a taxonomy field, but I'm not having much success. I checked the xslt from SPD, and copied it to my custom xslt file in VS2010, but it doesn't work.

This is the relevant part found in SPD (for the field "Country").

<xsl:template name="FieldRef_printTableCell_EcbAllowed.Country" match="FieldRef[@Name='Country']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="hide">
   <xsl:param name="thisNode" select="."/>
   <xsl:param name="class" />
<td>
   <xsl:if test="@ClassInfo='Menu' or @ListItemMenu='TRUE'">
     <xsl:attribute name="height">100%</xsl:attribute>
     <xsl:attribute name="onmouseover">OnChildItem(this)</xsl:attribute>
  </xsl:if>
   <xsl:attribute name="class">
     <xsl:call-template name="getTDClassValue">
        <xsl:with-param name="class" select="$class" />
        <xsl:with-param name="Type" select="@Type"/>
        <xsl:with-param name="ClassInfo" select="@ClassInfo"/>
     </xsl:call-template>
  </xsl:attribute>
  <xsl:apply-templates select="." mode="PrintFieldWithECB">
    <xsl:with-param name="thisNode" select="$thisNode"/>
  </xsl:apply-templates>
</td>

I tried modifying it by adding some random text messages inside the templates, so I know the xslt works, and finds the field. But it does not.

 <xsl:template match="FieldRef[(@Encoded) and @Name='Country']" ddwrt:dvt_mode="body" mode="Lookup_body" ddwrt:ghost="hide">
 Some random text
   <xsl:param name="thisNode" select="."/>
<xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" /></xsl:template>

Usually, "Some random text" should also appear in the field, if it was a user field, or number etc. but this time it does not.

So I was wondering maybe you have an idea on how this custom rendering for taxonomy fields can be done.

share|improve this question

2 Answers 2

Calling this template might be an issue

 <xsl:template match="FieldRef[(@Encoded) and @Name='Country'] ... >

I'm not sure but i think the call to this template is not really correct that is why you never see the text.

share|improve this answer
    
This is how I got the xslt from SPD. Rest assured I tried different combinations (even without the @Encoded part), but to no avail. –  florinszilagyi Jul 20 '12 at 13:27

In your case for rendering Taxonomy field in template the following attributes are specified correctly:

a) match attribute (value correspond to field internal name)

match="FieldRef[(@Encoded) and @Name='Country']"

b)mode attribute (Taxonomy field has Lookup type)

mode="Lookup_body"

Please remove another attributes, your template should look like shown below:

<xsl:template match="FieldRef[(@Encoded) and @Name='Country']"  mode="Lookup_body">
 Some random text
   <xsl:param name="thisNode" select="."/>
<xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" /></xsl:template> 
share|improve this answer

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.