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.

Calling Values from the lum_user database- Comment Count and Undernames

edited February 2008 in Vanilla 1.0 Help
Hello all, Here is my dillema, I hope someone can help me. I am currently designing a forum at http://the905board.com/board. Everything is going good so far I just have two things that I would like to add. 1. A comment count under the advatar of each user when they post. I know there is an extension for this, but it doesn't seem to work. Is there a way to call the values from the database and post them under the users advatar? Idealy without making 30 calls per page load. 2. We would like to have a thing we call an "under name" basically its a little tagline that is different for each user. They are assigned by admins. I would be happy If I could just add a collumn in the lum_user and just input the text that way. By using PHP I could call the value (along with the post count) and place them under the advatar of each user. Doesnt seem too hard, but I am stumped. Any help is really appreciated.

Comments

  • edited February 2008
    #2 is easier, so I'll address it first. Yes, you can simply add a column to the User table, and create some sort of form where the admin can add the "under name" tagline. I would add a delegate function that tells Vanilla to select the tagline along with all the other comment data---without looking, I think that one is in CommentManager class. Then, I would add a delegate function that adds the tagline data to the comment object---again without looking, that should be in the Comment class. Last, you need to modify the appropriate theme file to display the data.

    First off, for #1, what problems are you having with CommentAuthorInfo? It already does what you want, it will probably be easier to fix that then write something new.

    That said, there are a couple different ways to achieve #1 (I'm not sure off-hand how CommentAuthorInfo does it). You can join the Comment table to itself on User/AuthorID = User/AuthorID, Grouped By the original CommentID (not the second Joined CommentID), and then Count the number of comments per User/AuthorID. (That's the idea, but I would have to double check the actual SQL commands.) That would wrap it all under a single database call. It will obviously slow down the database call, but I have no idea by how much. If you do that, you could add the count data to the comment object like above.

    Another way would be to create another column on the User table, "CommentCount". Whenever a comment is saved, you up the counter for the appropriate user. Then you could pull and display the data the same way as the tagline. That would require more programming work, but it would lesson the time/strain to pull/process discussions. If you did that, you would probably want to periodically re-count everyone's comments, to ensure the integrity of the counter. Maybe re-count a user's comment's when they log in? I guess you could re-count a user's comments everytime they wrote a new comment, but that's probably over doing it.
  • SirNot's Signatures extension could do your undernames also. It might even be easy enough to edit it so that the post counts and the signatures are combined and both come through the same channel.

    Get that extension installed then try hacking it to get your post count alongside the signature... it'll probably be easier than you think.
  • Comment Author Info doesnt work with my theme. when it is installed nothing shows up. I am pretty good with the sql databases, but when it comes to acutally coding the PHP I am not too sure. Could you point me in the direction on how to do this?
  • That was a bit more complicated than I anticipated, but here is what I did:
    1. Install Signatures, but instead of the line given in it's install instructions, replace with this:$CommentList .= $Comment->Body.(defined('EXTENSION_IN_SIGNATURES') ? SignatureRender(@$Row['AuthUserPrefs'], @$Row['CountComments']) : ''). '
    2. Now we need to get that CountComments data from the database. This will piggyback on the call already made by Vanilla to get the comments themselves. To do that, edit Signatures/default.php, and inside the Signatures_CommentBuilder function, add this line to the one very similar line already there:$CommentBuilder->DelegateParameters['SqlBuilder']->AddSelect('CountComments', 'a', 'CountComments');
    3. A little further down, we need to accept the extra parameter that we specified in step 1, so add this CommentCount to the function name so it looks like this:function SignatureRender($UserPrefs, $CommentCount)
    4. Finally, at the bottom of the extension file we want to attach that comment count to the signature output of the extension, so change the line at the bottom to look like this:return '<span class="CommentSignature">Comments:'. $CommentCount . ' '.$Text.'</span>';
    Hope this helps!
This discussion has been closed.