Modules > Content rating > Content rating internals and API:
Adding document rating
Adding document rating
The following code example explains how content rating can be added to a document using the API.
[C#]
using CMS.DocumentEngine; using CMS.CMSHelper; int nodeId = 241; double rating = 0.5f;
// Gets the document TreeProvider tree = newTreeProvider(CMSContext.CurrentUser); TreeNode node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode);
// Adds the rating // If the 3rd parameter is true, information that the document has been rated is stored in a cookie. It is possible to check if the user rated the document. TreeProvider.AddRating(node, rating, false);