Bug reports Found a bug? Post it here please.
Version 5.x > Bug reports > Massive Bug in Rating Control View modes: 
User avatar
Member
Member
michael-liquidvision - 4/16/2010 12:26:14 AM
   
Massive Bug in Rating Control
Hi,

Can someone help to resolve this problem. The ExternalValue doesn't seem to work dynamically in the transformation. Here's my code:

<cms:RatingControl ID="elemRating" runat="server" Enabled="false" RatingType="Stars" CheckIfUserRated="false" CheckPermissions="true" AllowForPublic="true" ExternalValue='<%# MyFunctions.TrimText(Convert.ToString(CMS.GlobalHelper.ValidationHelper.GetDouble(GetSearchValue("DocumentRatingValue"), 0)/((CMS.GlobalHelper.ValidationHelper.GetDouble(GetSearchValue("DocumentRatings"), 0) == 0?1:CMS.GlobalHelper.ValidationHelper.GetDouble(GetSearchValue("DocumentRatings"), 1))))) %>' />

...but if I hardcode it like:

<cms:RatingControl ID="elemRating" runat="server" Enabled="false" RatingType="Stars" CheckIfUserRated="false" CheckPermissions="true" AllowForPublic="true" ExternalValue='0.73458' />

...it works and the stars appear

Please help. Thanks,

Benito

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 4/16/2010 3:58:41 AM
   
RE:Massive Bug in Rating Control
Hello,

Could you please try to use following expression for the ExternalValue property?

<%# Convert.ToString(CMS.GlobalHelper.ValidationHelper.GetDouble(Eval("DocumentRatingValue"), 0)/((CMS.GlobalHelper.ValidationHelper.GetDouble(Eval("DocumentRatings"), 0) == 0?1:CMS.GlobalHelper.ValidationHelper.GetDouble(Eval("DocumentRatings"), 1)))) %>


It is described in the Developer's Guide: http://devnet.kentico.com/docs/devguide/displaying_ratings_in_transformations.htm

Best regards
Ondrej Vasil

User avatar
Member
Member
michael-liquidvision - 4/18/2010 5:56:20 PM
   
RE:Massive Bug in Rating Control
Hi Ondrej,

If I used the Eval, it always returns zero value. The reason I am using 'GetSearchValue' in placed of the 'Eval' expression because I'm displaying the different documents from the Smart Search (using the transformation).

Have a look at this link: http://hin.cms.lvwebdev.com/search?searchtext=pears

I've edited the transformation so it displays the value for the ExternalValue using the the code but with 'GetSearchValue' expression.

It is the same code that is being used for the RatingControl. It doesn't work dynamically but if I hardcode using the same values, it works.

It must be a bug in the RatingControl itself.

Thanks,
Benito

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 4/26/2010 5:21:41 AM
   
RE:Massive Bug in Rating Control
Hello,

I see. Search results are quite specific in this context. The GetSearchValue method is being resolved too late in the control live cycle. Therefore you'll need to amend the Rating control to reload it again.

Please open the control here: ~\CMSAdminControls\ContentRating\RatingControl.ascx.cs

And please find the ExternalValue definition and add ReloadData() method to the set branch:

    /// <summary>
/// Gets or sets current value. If value is negative number then document
/// rating is used.
/// </summary>
public string ExternalValue
{
get
{
return mExternalValue.ToString();
}
set
{
mExternalValue = ValidationHelper.GetDouble(value, -1.0);
ReloadData();
}
}


Now it should work as expected even in the search results.

Best regards
Ondrej Vasil