Total Comment on Category

edited May 2007 in Vanilla 1.0 Help
Hi Guys, I know there is total discussions on category, but is there a way to display total comments number? Thanks

Comments

  • wait for it...
  • This comment talks about how to do this generally.
  • I think i have to use join to count the comment on each categories then since the comment tables does not have category ID
  • lechlech
    edited May 2007
    You'll want to tally a count on the CategoryID row.

    $Category->DiscussionCount
  • edited May 2007
    $dm = $Context->ObjectFactory->NewContextObject($Context, 'DiscussionManager'); $CategoryDiscussionCount = $dm->GetDiscussionCount($CategoryID);disclaimer: untested code
    Edit: Lech's method is better, if you have a proper category object already.
  • edited May 2007
    SELECT COUNT(LUM_Comment.CommentID) AS COUNT_CommentID, LUM_Comment.DiscussionID, LUM_Discussion.DiscussionID, LUM_Discussion.CategoryID, LUM_Category.CategoryID FROM LUM_Discussion INNER JOIN LUM_Comment ON LUM_Discussion.DiscussionID = LUM_Comment.DiscussionID INNER JOIN LUM_Category ON LUM_Discussion.CategoryID = LUM_Category.CategoryID GROUP BY LUM_Comment.DiscussionID, LUM_Discussion.DiscussionID, LUM_Discussion.CategoryID, LUM_Category.CategoryID WHERE LUM_Discussion.CategoryID = $Category->DiscussionCount Like that? sorry i'm a newbie in php and mysql :p
  • thanks i figured it out :p
This discussion has been closed.