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.
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.
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! :)
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.
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.
There is also this package from Tim Geyssens.
http://www.nibble.be/?page_id=4#starrating
http://our.umbraco.org/forum/using/ui-questions/6819-Ratings-Module
Not sure that package will work in V6.x though as it's a few years old now.
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! :)
is working on a reply...