Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Khai 71 posts 161 karma points
    Jun 25, 2013 @ 15:38

    How to implement a rating component?

    So I want to implement a rating component on documents. I also want to be able to generate lists with the top rated items etc.

    So what I have now is:

    - A custom table in the database that stores the rating. id, nodeId, memberId and ratingValue.

    It's no problem to update this table with some custom code but I'd like an easy way to get the rating of a document in code. I could create a method somewhere to return that rating but that's not what I want. I want to be able when I use the ContentService and it returns an IContent object that I can get the rating with a method on IContent.. Now the problem is, it's probably not possible to extend the IContent object with such an method, so I was thinking of the GetValue method, however it's necassary to create a custom datatype then. However I'm not sure how to implement this like a custom datatype. 

  • David Brendel 774 posts 2841 karma points c-trib
    Jun 25, 2013 @ 16:02
    David Brendel

    Why have you created a custom table when you want to get the value from an IContent object?

    If you had add the necessary settings to the document type you could just read them from the IContent object.

    I think the only way so would by to create a custom model which inherits from IContent and give it the new method. But then you have to convert every IContent to your new type.

    Or you build a custom version of umbraco and implement your method in the IContent type directly.

    Or you can build a static class which gets an id of a content item and fetch the rating from the custom table and returns it.

  • Matt Barlow ( 148 posts 657 karma points c-trib
    Jun 25, 2013 @ 17:06
    Matt Barlow (

    There is also this package from Tim Geyssens.

    Not sure that package will work in V6.x though as it's a few years old now.



  • Khai 71 posts 161 karma points
    Jun 26, 2013 @ 10:38

    Hi, thanks for your replies, I already found the starrating package but it does not comply with my requirement. I created a custom table because I think it's the best way to store ratings. I actually need the NodeId, MemberId ( So a member can't vote twice ), VoteValue and Date ( Date is required to create a list of best rated items of today or week, month, year etc. ) I guess i'll go with the static class method. If anyone has a better alternative, please let me know! :) 

Please Sign in or register to post replies

Write your reply to: