Add a Comments widget and Comments counter in a template

You can manage the comments in your website with the built-in CommentsWidget and CommentsCountControl

PREREQUISITES: To use the CommentsWidget and CommentsCountControl widgets, in your template you must add the following reference:
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Modules.Comments.Web.UI.Frontend" TagPrefix="comments" %>

Add the Comments widget

The example below displays how to add CommentsWidget in the details templates for News items and associate its type with the current news item. It has the following properties:
  • ThreadKey property
    To use the widget, you must specify its ThreadKey property. When you set the ThreadKey property of the CommentsWidget you ensure that the comments submitted in this CommentsWidget are stored in a specific thread. This allows you to have more than one Comments widget on the same page and they display different comments. To do this, set two different ThreadKeys to each widget. This is useful, if you want to allow the users to comments different items displayed on the same page. 

    By setting the ThreadKey, you ensure that for every translation the CommentsWidget is associated with different threads. This way you can have different comments for the different translations of your items. 

  • GroupKey property
    You can set the GroupKey property of the CommentsWidget. This way, you can specify the group that is associated with the thread. 
  • ThreadType property
  • You can set the ThreadType property of the CommentsWidget. This property associates the widget with some item type. Then, you can control the thread settings by clicking Adimistration » Settings » Advanced » CommentsModule » CommentableTypes.

If you do not set the GroupKey and the ThreadType properties your CommentsWidget is automatically associated with the current page. Sitefinity CMS creates a new thread for this CommentsWidget when the first comment is submitted. In this case, if you drop two CommentsWidget on the same page they display the same comments. 

NOTE: If you want to have two different items with the same list of comments, you can set the ThreadType and GroupKey for both CommentsWidgets to the same values.

Add comments count

Sitefinity CMS has a separate widget that displays the count of the comments associated with particular thread.

The example below displays how to add the CommentsCountControl in News template. 
It has the following properties:

  • ThreadKey property
    To use the widget, you must specify its ThreadKey property. Sitefinity CMS uses it to associate the count with the specific thread. 
  • NavigateUrl property
    You can use the NavigateUrl property to modify the default redirection. 
  • DisplayMode property
    Sitefinity CMS has the following display modes for this widget: 
    • DisplayMode="ShortText"

    • DisplayMode="FullText"

    • DisplayMode="IconOnly"

Use the following template example:

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?