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 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>
share|improve this question
add comment

4 Answers

you can use @ContentType as well.

share|improve this answer
add comment

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

share|improve this answer
    
You are right the ending for if statement needed /. Now I dont get error but the icon's are not showing up. –  Alicia Davis Jul 23 '12 at 14:17
    
Well, care to update your code? I'll see what I can do to help. –  RJ Cuthbertson Jul 23 '12 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. –  Alicia Davis Jul 23 '12 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. –  RJ Cuthbertson Jul 23 '12 at 15:24
add comment

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> 
share|improve this answer
add comment

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.

share|improve this answer
    
I am unable to Mark this post as answer (Dont even see that option). Can someone please mark this post as an answer. Thanks –  Alicia Davis Jul 24 '12 at 13:50
add comment

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.