More in this section

Forums / Developing with Sitefinity / Count all forum posts

Count all forum posts

3 posts, 1 answered
  1. Philip Senechal
    Philip Senechal avatar
    69 posts
    Registered:
    07 Apr 2008
    10 Jul 2009
    Link to this post
    I've been trying to figure out how to do a count of all forum posts on the site. I think the only way I can do this is by using GetPostsByAuthor, but I can't seem to figure out how to do a wildcard search. * and % don't work. Is there a way to search for posts by all authors or is there another way I can count all the forum posts on the site? Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Jul 2009
    Link to this post
    Hello Philip Senechal,

    Here is a logic that will return the number of all posts.

      ForumManager manager = new ForumManager(); 
            IList allForums = manager.GetForums(false); 
            int totalPosts = 0; 
            if (allForums.Count > 0) 
            { 
                foreach (IForum forum in allForums) 
                { 
                    Response.Write(forum.Name + "-" + "Number of posts: " + forum.Posts.Count.ToString() + "<br/>"); 
                    totalPosts += forum.Posts.Count; 
                } 
            } 
            Response.Write(totalPosts); 


    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Answered
  3. Philip Senechal
    Philip Senechal avatar
    69 posts
    Registered:
    07 Apr 2008
    10 Jul 2009
    Link to this post
    Perfect...thank you.

    I had found a section of the API manual that talked about looping through all the forumns and thought this might be the way to go and you confirmed it for me.
Register for webinar
3 posts, 1 answered