Dave Burke : Online Community and Social Business Specialist

Converting Community Server Comments into Customer Reviews

This Community Server mod was too much fun not to blog about. Blog Post Comments as Customer Reviews. We all know users can rate a post, but displaying an individual star rating per "comment" is not something you see every day. This is what we're talking about.



Here's the skinny on converting comments into customer reviews. The rating widget used in the comment form is the Ajax Toolkit Rating Control. Custom WeblogPostCommentForm coolness was in adding the AjaxControlToolkit Rating control as if it were your everyday TextBox. Worked like a charm.

protected AjaxControlToolkit.Rating customerRatingStars;

protected override void AttachChildControls()
{
    customerRatingStars =
        CSControlUtility.Instance().FindControl(this, this.customerRatingStarsId)
        as AjaxControlToolkit.Rating;


and so forth. The star rating (1 through 5) is stored in a separate drive_Ratings table as an integer OnSubmit().


BlogPostResults result = WeblogPosts.Add(c, csContext.User, out postID);

CustomerRating customerRating = new CustomerRating();
customerRating.Rating = customerRatingStars.CurrentRating;
customerRating.PostID = postID;
Directories.CreateCustomerRatingEntry(customerRating);


For simplicity sake I created five separate star images associated with each of the possible five ratings, then a ReviewStarImage Wrapped Content control to display it.  The essential control logic being

CommunityServer.Controls.Image image = new CommunityServer.Controls.Image();
int postID = _weblogCommentPost.PostID;
int stars = Directories.GetCustomerRating(postID);
image.ImageUrl = "/images/common/stars/" + stars.ToString() + ".png";
control.Controls.Add(image);


For ultimate performance it would have been better to extend the WeblogPost object used with the reviews to retrieve the rating as part of the post, but that's a lot of typing.  So we plop in the ReviewStarImage control as part of the WeblogFeedbackData item and we got stars.

<DRIVE:ReviewStarImage runat="server" />


Now where did I put that "Community Server" category tag?

Comments (2) | Post RSS RSS comment feed

Posted on 6/9/2009 1:54:33 PM by Dave Burke
Categories: Community Server
Tags:

Related posts

Comments (2) -

6/9/2009 3:40:41 PM Permalink

Much more elegant than my solution to this problem was - I ended up writing a custom CS Application.  (OK, when I said custom, there was a fair amount of copy paste from the blog application but still...).

Alex Crome United Kingdom |

6/9/2009 4:31:48 PM Permalink

Copy and paste is OKAY!  It's those little additions that make all the difference. Smile  Great to hear from you.  Thanks.  A compliment from you means a lot.

daveburke United States |


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke

Copyright © 2013 Dave Burke.  All Rights reserved.