API Questions on Kentico API.
Version 6.x > API > Posts and Thread counts for community View modes: 
User avatar
Certified Marketer 13
Certified Marketer 13
bruce.williams-thundertech - 10/31/2012 2:56:05 PM
   
Posts and Thread counts for community
Would this be a good function to pull that or is there a simpler way?

Public Sub DisplayTotalPosts()
Try
Dim users As Data.DataSet = CMS.Forums.ForumPostInfoProvider.GetForumPosts("", "", 0, "postid")
If DataHelper.DataSourceIsEmpty(users) = True Then Me.Literal1.Text = "0" : Exit Sub
Dim totalthreads As Integer = 0
For Each f As Data.DataRow In users.Tables(0).Rows
Dim forumpost As CMS.Forums.ForumPostInfo = CMS.Forums.ForumPostInfoProvider.GetForumPostInfo(f("postid"))
If forumpost IsNot Nothing Then
totalthreads += forumpost.PostThreadPosts
End If
Next
Me.Literal4.Text = totalthreads

Me.Literal3.Text = users.Tables(0).Rows.Count.ToString


Catch ex As Exception
' Me.Literal3.Text = ex.Message & ex.StackTrace
End Try

End Sub

User avatar
Member
Member
kentico_davidb2 - 11/2/2012 5:10:29 AM
   
RE:Posts and Thread counts for community
Dear Bruce,

you could also make use of the

ForumThreads and ForumPosts properties of

Namespaces ► CMS.Forums ► ForumInfo class.

Dave