0

I am trying to change the icon for the "Link to Document" on the searchResult.aspx page. I added following to the xslt of the result but then the result webpart never renders meaning the code is broke. I tried to follow SP2007 article (http://msdn.microsoft.com/en-us/library/cc789805(v=office.12).aspx) but my environment is SP 2010. Please suggest.

<xsl:choose> 
<xsl:when test="contenttype='LegalLinkedDocument'"> 
<img align="absmiddle" src="_layouts/images/legalIcon.gif" border="0" alt="{imageurl/@imageurldescription}" />
</xsl:when>
<xsl:otherwise>
 <img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" /> </xsl:otherwise>
</xsl:choose>

4 Answers 4

2

you can use @ContentType as well.

1

You need to close the nodes. You never close out your xsl:if statement.

http://www.w3schools.com/xsl/xsl_if.asp

Just like XML, every tag needs a beginning and end.

I'm not sure exactly what you're doing here, but I think an xsl:choose statement might be more appropriate to handle the else portion of the if...else statement via xsl:otherwise.

http://www.w3schools.com/xsl/xsl_choose.asp

4
  • You are right the ending for if statement needed /. Now I dont get error but the icon's are not showing up. Commented Jul 23, 2012 at 14:17
  • Well, care to update your code? I'll see what I can do to help. Commented Jul 23, 2012 at 14:48
  • I updated the code from IF to When so I can put Otherwise. The result webpart renders without any error but the desire icon for content type is not showing. Commented Jul 23, 2012 at 14:56
  • Sounds like your test statement isn't resulting in true. Are you sure contenttype is the property you need? The article talks about a contentclass value. Commented Jul 23, 2012 at 15:24
1

Try putting the contenttype value into a variable before using it in the condition

<xsl:variable name="contenttype" select="contenttype"/>
<xsl:choose>  
  <xsl:when test="$contenttype = 'LegalLinkedDocument'">  
    <img align="absmiddle" src="_layouts/images/legalIcon.gif" border="0" alt="{imageurl/@imageurldescription}" /> 
  </xsl:when> 
  <xsl:otherwise> 
    <img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" />
  </xsl:otherwise> 
</xsl:choose> 
0

I followed this link and then compared:

<xsl:when test="ctype='LegalLinkedDocument'"> 

Now it's all good.

@Per Jakobsen: Your solution did not work for me.

1
  • I am unable to Mark this post as answer (Dont even see that option). Can someone please mark this post as an answer. Thanks Commented Jul 24, 2012 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.