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
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.
0
This discussion has been closed.
Comments
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.
Get that extension installed then try hacking it to get your post count alongside the signature... it'll probably be easier than you think.
- Install Signatures, but instead of the line given in it's install instructions, replace with this:
- 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:
- 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:
- 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:
Hope this helps!$CommentList .= $Comment->Body.(defined('EXTENSION_IN_SIGNATURES') ? SignatureRender(@$Row['AuthUserPrefs'], @$Row['CountComments']) : ''). '
$CommentBuilder->DelegateParameters['SqlBuilder']->AddSelect('CountComments', 'a', 'CountComments');
function SignatureRender($UserPrefs, $CommentCount)
return '<span class="CommentSignature">Comments:'. $CommentCount . ' '.$Text.'</span>';