Is this really the version you are looking for? Kentico 8 documentation is no longer updated. Use the switch in the header to choose your Kentico version.

Using the Content rating web part

The Content rating web part can be added to any web part zone on any page of your website, enabling users of the website to rate the content of the currently displayed page or document. The web part has three default appearance modes:

Stars Radio-buttons Drop-down list

You can also create other appearance modes by creating your custom controls. Place the custom controls in ~/CMSAdminControls/ContentRating/Controls/ and inherit from CMS.ExtendedControls.AbstractRatingControl.

Below is a list of specific properties of the web part:

  • Rating value - this property can be used to set the displayed rating value explicitly. A value from the <0,1> interval can be used, while 0 represents the lowest rating and 1 represents the highest rating on the scale defined by the Max rating value. If blank, the real rating calculated as an average value of particular ratings is displayed.
  • Rating type - appearance of the web part. You can choose from Stars, Radio-buttons or Drop-down list.
  • Max rating value - size of the rating scale. For example, if 7 is entered, rating will be possible on a scale from 1 to 7.
  • Show results - if checked, overall rating results will be displayed. If unchecked, users can rate, but don't see the results.
  • Result message - message showing overall rating results. The {0} macro shows overall rating (for one decimal rounding, you can use {0:0.#} ). {1} displays the total number of votes.
  • Message after rating - text message displayed after a user submits their rating. Macros that can be used: {0} your rating, {1} overall rating, {2} overall number of votes.
  • Check permissions - if enabled, permissions set by the Allow for public and Hide to unauthorized roles properties will be checked.
  • Allow zero value - if enabled, users are allowed to submit ratings with zero value (no rating value selected).
  • Error message - message displayed to users who try to submit a rating with zero value. Applied only if the Allow zero value option is disabled.
  • Anonymous users can rate - if enabled, rating will be allowed to public unauthorized users. If unchecked, only authenticated users will be allowed to rate.
  • Check if user rated - if enabled, users will be allowed to vote only once. To indicate that the user already voted, Kentico stores a DocRated cookie in your web browser, the cookie contains NodeIDs of the rated documents separated by the pipe character (e.g. |4|61|229|230|228|369|).
  • Hide to unauthorized users - if enabled, the web part will be hidden to unauthorized users.

Example: Adding news ratings

You can place the Content rating web part on any page of your website to enable users to rate the content of this particular page. In the following example, you will add the web part to news items on the sample Corporate Site. A similar result can also be achieved using transformations, as described in Displaying content rating in transformations.

  1. Open the Pages application, switch to the Design mode and select News in the content tree.
  2. Add the Content rating web part to the Main zone.
  3. In the Web part properties dialog, configure the following property:
    • Show for document types: cms.news; this ensures that the web part will be displayed only for the particular news items and not for the list of news on the title page of the News section.

Now go to the live site and view the New Consulting Services news item. You should see the web part below the news text as in the screenshot below. Try rating the page.

Rating a document

To view the overall rating, open the Pages application and view Properties of the news item. The Rating property on the General tab reflects the current rating of the selected document. All ratings are recalculated to 10 step scale and displayed as stars here, no matter what the settings of the web part are.