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 > 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) <= $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) > $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) <= $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) > $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) <= $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) > $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) <= $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) > $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-->