Voting and Rating


I'm trying to use the Contrib.Voting and Contrib.Reviews modules. I've made some changes to the Contrib.Stars.js as mentioned in this stackoverflow post.

I have also made a few changes to to add a "total" to the Parts.Stars.Details.cshtml. I am now stuck. Is there a way to show the Reviews as regular content items? Right now, you can only change the star rating but not edit an existing review. You can only delete it.

How would I redesign the Review module to make Reviews/Ratings show up as regular content items? Can I turn the Voting into a content part? Any help would be appreciated.

Thanks in advance.

Re: Voting and Rating

To turn reviews into content items you'd basically have to define a new type (e.g. Review) and create content items of that type in the ReviewController instead of instances of the ReviewRecord class.

However, unless you want to extend the Review entity, it is probably simplest to write a controller that lets you edit review records.

Not sure what you mean by turning Voting into a content part, but there is a VotingWidgetPart that you may want to use?

Sunday, February 22, 2015 11:32:56 PM bysfmskywalker

Re: Voting and Rating

Thanks for the reply, Sipke.

Currently, in the ReviewController, a new ReviewRecord is created and it's setting the ContentItemRecordID and the VoterecordID, to maintain who voted on what contentitem.

var review = new ReviewRecord {Comment = comment, CreatedUtc = _clock.UtcNow, ContentItemRecordId = contentId, VoteRecordId = userVote.Id}; _reviewRepository.Create(review); _orchardServices.Notifier.Information(T("Thank you for submitting your review."));

Assuming I have created a Review Content Item, do I use contentManger and set the associated properties? var review = _contentManager.New("Reviewt");

Monday, February 23, 2015 8:08:05 PM byMattDunn

Re: Voting and Rating

Yes exactly, use IContentManager to create a new review and set its properties. Assuming you'd have a ReviewPart, you could create a new review content item like so:

var review = _contentManager.New<ReviewPart>("Review");

This way you'll instantly get a reference to the ReviewPart on your content item so that you can set its properties.

Thursday, February 26, 2015 11:36:26 AM bysfmskywalker

Post a reply

You need to be signed in to post a reply.

Sign In