More in this section
Forums / Developing with Sitefinity / Testing blog comment publish status

Testing blog comment publish status

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Ben Wright
    Ben Wright avatar
    2 posts
    06 Apr 2006
    13 Oct 2010
    Link to this post

    I am using SiteFinity 3.7 SP2. I am getting a list of blog post comments. I want to filter out the comments that are not published. How do I go about doing this? As usual, I can't anything beyond the basics in the documentation... Below is the pertinent code:





    listofComments = from blogs in listOfBlogs.OfType<IBlog>()




    from blogposts in blogs.Posts.OfType<IContent>()




    from comments in blogposts.Comments.OfType<IComment>()




    orderby comments.Parent.DateCreated descending




    select new {


    comment = comments,

    blogpage = blogs.BlogPage





    if (listofComments.Any()) {




        IComment commentItem = default(IComment);




        for (int idx = 0; idx <= Math.Min(mCommentCount - 1, listofComments.Count() - 1); idx++) {


            commentItem = listofComments.ElementAt(idx).comment;





    "<a href=\"" + GetUrl(listofComments.ElementAt(idx).blogpage.Replace
    ".aspx", "/") + commentItem.Parent.UrlWithExtension) + "\">");


            output.Append(commentItem.Text.Substring(0,(mMaxCommentTextLength == 0 ? 
                commentItem.Text.Length :


                commentItem.Text.Length))) +
    "..." + "</span>");







  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    13 Oct 2010
    Link to this post
    Hi Ben,

    The IComment object does not have a status like Published -NotPublished. There are visible and not visible comments. You can filter comments by their visibility by using this code

    // contentItem is the IContent object  - your blog post
    var listofComments = contentItem.Comments.Cast<IComment>().ToList().Where(c => c.Visible = false);

    You can use GetComments method of ContentManager class to get a list of all comments per provider. The method has 7 overloads which allows you to get posts by content ID, filter, sort them etc.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered