Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

$Comment->UserCommentCount in 0.9.3 (comments.php)

edited April 2006 in Vanilla 1.0 Help
Is this variable supposed to work? I see that it is defined, but it doesn't seem to contain the actual number of comments the user has made; they all show 0. Is this a new feature that has not been completed yet? Thanks!


  • ithcyithcy New
    edited April 2006
    try $Context->Session->User->CommentCount ?

    *is not certain
  • Well, I'm doing this in comments.php because I'd like to show a comment count next to each post, rather than just the comment count of the actual user browsing the forum.
  • ithcyithcy New
    edited April 2006
    ah. nevermind.

    you mean you're trying to show how many comments have been made by each user just in that particular thread?
  • nope, I want to show total user comments, like a lot of the more mainstream forums use. So the kids who sit on the forum all day get some kind of sense of self-worth ;)
  • edited April 2006
    // Used to prevent double posts and "back button" posts var $UserCommentCount;

    So I think you've misinterpreted the use of that variable.

    On the bright side, $Context->AuthUserID will get you the comment's author's ID numbert. The UserMananger's class' "GetUserById" function can then be used to return the Author's User object, which has a comment count as a field.
  • I sure did, Bergamot. Thanks for the info. I'm afraid that putting ~30 GetUserById calls on this page will really bog down the server though, so maybe I'll either skip it or try to build that functionality into the code where comments are pulled. It would be nice, but certainly not worth a huge server hit like that. I haven't had too much time to dig through the code, but if we need the feature I'll have to get my hands dirty. Thanks.
  • You just found the exact reason vanilla is so clean and simple :)
  • MarkMark Vanilla Staff
    edited April 2006
    Hmmm. Interesting problem. Yeah - I realize that the UserCommentCount is a little misleading. Probably should have named it something else.

    But to address your problem, I just added two new delegates to the CommentManager class that will allow you to alter the SQL queries that retrieve comments.

    $this->DelegateParameters['SqlBuilder'] = &$s; $this->CallDelegate("CommentManager_GetCommentList");

    Using delegation you can now add new joins and columns to that query. Then you can change up a template to display whatever new columns you've selected.
  • edited April 2006
    Can you register a function to a delegate within any of the theme files, or would you need a matching extension?
  • MarkMark Vanilla Staff
    Well, you shouldn't be putting functions within theme files because the theme files are included from within control methods themselves. Maybe I've misunderstood you, though.
  • MarkMark Vanilla Staff
    If you're asking if there can be delegates within theme files, then the answer is yes.
This discussion has been closed.