Modules > Content rating > Content rating internals and API:
Modifying document rating
Modifying document rating
The following code example shows how rating of a document can be modified using the API.
[C#]
using CMS.DocumentEngine; using CMS.CMSHelper; int nodeId = 241; double rating = 1.0f; int numOfRatings = 2;
// Get the document TreeProvider tree = newTreeProvider(CMSContext.CurrentUser); TreeNode node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode); // Modify its rating TreeProvider.SetRating(node, rating, numOfRatings);