More in this section

Forums / Developing with Sitefinity / Blog rating in sitefinity 4.2

Blog rating in sitefinity 4.2

4 posts, 0 answered
  1. Chirag
    Chirag avatar
    1 posts
    Registered:
    26 Sep 2011
    11 Oct 2011
    Link to this post
    Can anyone tell me how to do blog rating in sitefinity 4.2?
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    14 Oct 2011
    Link to this post
    Hi Chirag,

     Here's what you can do - : you can use RadRating control for ASP.NET AJAX:
    http://demos.telerik.com/aspnet-ajax/rating/examples/gridrating/defaultcs.aspx

    You have to implement custom control that will have a client part and ListView (or another control) with BlogPosts, that will wrap rad rating control in the Item Template.

    The average rating result need to be calculated at wrapper rating control like:

    var averageRating = ratedItem.VotesSum / (ratedItem.VotesCount != 0 ? ratedItem.VotesCount : 1);
    //load the value
    this.RatingControl.Value = (double)averageRating;

    On the client  you need to implement a method that will invoke service to update VotesCount and VotesSum into the database (these could be custom fields of the BlogPosts).

    Kind regards,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    08 Nov 2011
    Link to this post
    Hi, could you expound more on how this is done:
    "On the client  you need to implement a method that will invoke service to update VotesCount and VotesSum into the database (these could be custom fields of the BlogPosts)."

    Thanks.
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    08 Nov 2011
    Link to this post
    Hi Jkregala,

     After you have calculated the average result of the Rating control, you can send it to the server using jquery to consume a POST service that will later update the two custom fields of the Blog Posts with the data from the service (which will be the VotesCount and the VotesSum).
    Please check this blogpost for information on how to consume the service using jquery:
    http://pranayamr.blogspot.com/2011/03/rest.html
    Also, in order to update the custom fields you can use the DataExtensions.SetValue method:

    Telerik.Sitefinity.Model.DataExtensions.SetValue(blogPost
    , "VotesSum", SumValue);
                
    Regards,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 0 answered