Sitefinity CMS allows you to modify a comment through the Comments API.
When modifying a news comment, you must perform the following:
Get the news item.
First, get an instance of the master version of the news item that corresponds to the specified ID.
For more information about finding specific news items, see For developers: Query news items.
Get the live version.
The instance that corresponds to the ID argument is the master version of the news item. You can get the live version explicitly.
Get the comment.
Get the comment that corresponds to the specified ID.
Modify the comment.
After you get the comment, you modify it.
Save the changes.
Finally, you save all changes.
The following examples modify a news comment by its ID.
ModifyCommentByIdNativeAPI(Guid masterNewsId, Guid commentId,
NewsManager newsManager = NewsManager.GetManager();
// Check whether the news item exists
NewsItem news = newsManager.GetNewsItems().Where(nI => nI.Id == masterNewsId).FirstOrDefault();
news = newsManager.Lifecycle.GetLive(news)
// Get the comment
Comment comment = newsManager.GetComments().Where(c => c.CommentedItemID == news.Id && c.Id == commentId).SingleOrDefault();
// Modify the comment
comment.Content = newContent;
// Save the changes
First, you get an instance of the NewsManager class. You get the specified news item by querying all items and filtering the collection by the ID property.
If the item exists, you get its live version. Then, you get the comment by calling GetComments and filtering based on theCommentedItemID and Id properties. Then, you modify the content of the comment with newContent. Finally, you save the changes.
ModifyCommentByIdFluentAPI(Guid masterNewsId, Guid commentId,
newsCount = 0;
App.WorkWith().NewsItems().Where(nI => nI.Id == masterNewsId).Count(
(newsCount > 0)
var liveNewsItem = App.WorkWith().NewsItem(masterNewsId).GetLive();
commentCount = 0;
// Check whether the comment exists
liveNewsItem.Comments().Where(c => c.Id == commentId).Count(
(commentCount > 0)
c.Content = newContent;
First, you use the plural facade of the news item to assure that the item with the specified Id exists.
Then, you use the GetLive method of the singular facade to get the instance of the live version. You initialize the plural facade of the comments by calling Comments. Then, you get the comment by filtering based on the Id property. You modify the content of the comment with newContent. Finally, you save the changes.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important
Copyright © 2023 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, Ipswitch, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.
Powered by Progress Sitefinity