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 add rating stars to the search results in my Enterprise Search Center site according to the instructions found on the following sites:

MSDN | Corey Roth - MVP's Blog | Todd's Blog

The instructions were simple enough to follow, but when I search I cannot get the stars to appear. I have tried a number of different things at this point but I am not aware of any XSL debugger, so I have been at a loss. I know the ratings have been crawled because I was able to successfully search for items with specific ratings.

Anybody else have this problem (and hopefully a solution)?

Thanks,

  • Matt

EDIT 3/14/2012:

Following is the XSL I added to the Core Search Results web part:

In the bottom of the div with the class "srch-Title3":

<!--Start Rating-->
<xsl:call-template name="FormatRating">
    <xsl:with-param name="theRating" select="rating"/>
    <xsl:with-param name="theRatingCount" select="ratingcount"/>
</xsl:call-template>
<!--End Rating-->

In the bottom of the XSL sheet, before </xsl:stylesheet>:

<!--Start Rating-->
<xsl:template name="FormatRating">
    <xsl:param name="theRating"/>
    <xsl:param name="theRatingCount"/>
   <xsl:if test="$theRating > 0">
     <div style="display: inline-block; padding-left: 8px;">
       <div>
         <xsl:variable name="tempTitle" select="concat($theRating, ' Stars (')"/>
         <xsl:variable name="tempTitle2" select="concat($theRatingCount, ' Ratings)')"/>
         <xsl:variable name="ratingTitle" select="concat($tempTitle, $tempTitle2)"/>

         <xsl:attribute name="title">
           <xsl:value-of select="$ratingTitle"/>
         </xsl:attribute>
         <xsl:choose>
           <xsl:when test="round($theRating) = 0 and $theRating &gt; 0">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-368px 0px;width:16px;</xsl:attribute>
           </xsl:when>
           <xsl:when test="round($theRating) = 1 and round($theRating) &lt;= $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-352px 0px;width:16px;</xsl:attribute>
           </xsl:when>
           <xsl:when test="round($theRating) = 2 and round($theRating) &gt; $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-352px 0px;width:32px;</xsl:attribute>
           </xsl:when>
           <xsl:when test="round($theRating) = 2 and round($theRating) &lt;= $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-336px 0px;width:32px;</xsl:attribute>
           </xsl:when>
           <xsl:when test="round($theRating) = 3 and round($theRating) &gt; $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-336px 0px;width:48px;</xsl:attribute>
           </xsl:when>
           <xsl:when test="round($theRating) = 3 and round($theRating) &lt;= $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-320px 0px;width:48px;</xsl:attribute>
           </xsl:when>
           <xsl:when test="round($theRating) = 4 and round($theRating) &gt; $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-320px 0px;width:62px;</xsl:attribute>
           </xsl:when>
           <xsl:when test="round($theRating) = 4 and round($theRating) &lt;= $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-304px 0px;width:64px;</xsl:attribute>
           </xsl:when>
           <xsl:when test="round($theRating) = 5 and round($theRating) &gt; $theRating">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-304px 0px;width:80px;</xsl:attribute>
           </xsl:when>
           <xsl:when test="round($theRating) = 5">
             <xsl:attribute name="style">background-image:url(/_layouts/images/Ratings.png);cursor:default;height:16px;margin:0px;background-repeat:no-repeat;background-position:-160px 0px;width:80px;</xsl:attribute>
           </xsl:when>
         </xsl:choose>
       </div>
     </div>
   </xsl:if>    
</xsl:template>
<!--End Rating-->
share|improve this question
    
I will say that I was able to search using Rating=4.0 and get results. My problem is just displaying the results as either a number or stars. –  Matt May 21 '12 at 15:56
add comment

1 Answer 1

up vote 0 down vote accepted

without digging into the XLST it's almost impossible to guess at an answer. I'd suggest you fall back to Cory's display method of showing the rating as Text to verify that you're getting the value properly into the results and then look at incorporating the flash graphics.

share|improve this answer
    
There are no flash graphics. It is just html and css, but that is besides the point. I pretty much copied and pasted from Todd's blog, naming my fields "Rating" and "RatingCount," respectively. I tried doing Cory's method, in addition. Per your suggestion, I commented out the part that calls the xsl template and replaced it with a simple call to the managed property (all lower-case for some reason, like the examples) and I got nothing. –  Matt Mar 12 '12 at 21:48
    
does your property show up if you use the MSDN XSLT that lists all the managed properties? –  GavinB Mar 13 '12 at 22:24
    
used the following code <xsl:for-each select="@*"> <br /> Name: <xsl:value-of select="name()" /> Value:<xsl:value-of select="." /> </xsl:for-each> but no dice –  Matt Mar 14 '12 at 15:53
    
You added the new managed property to the list of columns to be selected right? –  GavinB Mar 14 '12 at 19:47
    
Yes, I also tried adding it to the parameters section for the xsl, but that caused it to break even more (no search results would display at all) –  Matt Mar 14 '12 at 19:54
show 2 more comments

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.