Exploding Garrmondo Weiner Interactive Swiss Army Penis

Exploding Garrmondo Weiner Interactive Swiss Army Penis (http://www.gamingforce.org/forums/index.php)
-   Help Desk (http://www.gamingforce.org/forums/forumdisplay.php?f=36)
-   -   vBulletin Question (http://www.gamingforce.org/forums/showthread.php?t=15510)

Diversion Dec 2, 2006 04:59 AM

vBulletin Question
 
I have a question about vBulletin post count. I noticed that it has only been counting total posts still in the database on my own forums. So if I were to purge an old board, most post counts would go down. Now for most post count doesn't matter, but for functional purposes of the board (a level system very similar to the one we have here), I would like to try to have it keep track of total posts ever made, whether it's still in the database or not. Any idea how to adjust this?

Thanks in advance.

Edit: I checked the database and noticed that there is a "post" column which outlines a user's post count. Instead of querying total posts, it just updates this post counter whenever posts are deleted, so just need to find an option to disable that negative increment.

Bigblah Dec 2, 2006 06:53 AM

A better way would be to add a new field to the user table instead -- this way you don't end up modifying original forum behaviour. Assuming your vBulletin tables have no prefix, you could run this query:

Code:

ALTER TABLE user ADD totalposts int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER posts
And then, to populate them initially,

Code:

UPDATE user SET totalposts = posts
From now on, the 'totalposts' field will be available through $vbulletin->userinfo['totalposts'], or $bbuserinfo['totalposts'] for templates. To update totalposts whenever someone successfully makes a post, you could use the Plugin Manager to add the necessary code to, say, the postdata_postsave plugin hook. (Doing this will also circumvent non-postcount forum behaviour.)

Code:

$this->dbobject->query_write("UPDATE " . TABLE_PREFIX . "user SET totalposts = (totalposts + 1) WHERE userid = " . intval($this->fetch_field('userid')));
I haven't tried it out myself, hopefully it works :)

(Note: the database object above corresponds to vBulletin 3.5x, you should check if your own install has the same syntax.)

Diversion Dec 2, 2006 06:55 AM

About to give it a try in a moment, I'll post results. Thank you!

Edit: I got the hook in there, found everything right, and I didn't get a syntax error of any kind. When I checked the database, the regular post count would update, but total wouldn't. I'll keep working with this through the day. If you happen to see what it may be, let me know. Thanks again!

Edit 2: Nope, it did work, I just added a quote in there for some odd reason: works perfectly. Thank you!!

Bigblah Dec 2, 2006 07:08 AM

What's your vBulletin version?

Edit: No problem =D

Diversion Dec 2, 2006 07:20 AM

Actually, if I may, I have one more question.

I had originally written a hack for IPB 2 years back which basically created an RPG-based aesthetic to the side. vBulletin definitely has a much different approach to coding (I'll attach the old code: it's VERY crude). It was basically a function of the total post count which ran through a bunch of different math functions to create the final 3 bars, though for true RPG fans the bars bear no usefulness whatsoever.

Would it be within the plugins section that I should put this mod (I will recode to fit vB) so that it'll execute with each post?

Bigblah Dec 2, 2006 07:48 AM

Yeah, a common hook location to use would be postbit_display_complete. The totalposts value (specific to each postbit) should be available as the $post['totalposts'] variable.

Diversion Dec 2, 2006 08:27 AM

Awesome, thanks again, gonna tweak with it and see what I come up with!

Edit: Going to throw one more question out there. If I want, within this function, to set a variable equal to an item in the database, I tried:

Code:

$this->dbobject->query("SELECT totalposts FROM user WHERE userid = " . intval($this->fetch_field('userid')));
Based off of what was written earlier, but it doesn't seem to select anything. Any idea what I may be doing wrong?

Double Post:
Bigblah is my vB hero! <3


All times are GMT -5. The time now is 08:50 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2025, vBulletin Solutions, Inc.