The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Reputation Divided by Post Count Displayed as %
I'm looking for someone who can help me with something. I want to be able to divide my users reputation by their post count, derive a % from it, and display it in each users postbit. I'd like to call it "Tip Ratio". This is necessary for our forum, but I can't quite figure out how to do it. Example to derive the "Tip Ratio":
Reputation: 206 Join Date: Mar 2011 Posts: 1,064 Tip Ratio: 19.4% (where 206/1064) Anyone interested in taking this on? |
#2
|
|||
|
|||
A great coder took care of me. I appreciate it!
|
#3
|
|||
|
|||
someone else want to post how this was done?
|
#4
|
|||
|
|||
Maybe something like this: create a plugin using hook location postbit_display_complete and code like:
Code:
if ($post['posts'] > 0) { $post['tip_ratio'] = vb_number_format($post['reputation'] / $post['posts'], 1); } else { $post['tip_ratio'] = '--'; // shouldn't ever happen, but protect against divide by 0. } Then use {vb:raw post.tip_ratio} in your postbit or postbit_legacy template. |
Благодарность от: | ||
CAG CheechDogg |
#5
|
|||
|
|||
Quote:
ie, a user with 109 posts and 7 rep got a "0.1" how would i get the number to display as "6.4%"? |
#6
|
|||
|
|||
Yeah, that happens a lot when I post code I didn't test. I think maybe it needs a "* 100" before the comma in the vb_number_format line (sorry, I would post the code but i'm using my pad and it's too hard to enter all that).
|
#7
|
|||
|
|||
nah, that just multiplied the weird number by 100
ie, user with 170 rep and 1,739 posts gets "17,000.0" rep/posts should be 0.097, or if multiplied by 100 to get that % figure, 9.7% i tried for testing purposes: Quote:
Quote:
|
#8
|
|||
|
|||
Try this:
Code:
if ($post['posts'] > 0) { $post['tip_ratio'] = vb_number_format($post['reputation'] / $post['posts'] * 100, 1); } else { $post['tip_ratio'] = '--'; // shouldn't ever happen, but protect against divide by 0. } |
#9
|
||||
|
||||
This is the code kh99 gave me to get the Tip Ratio for times thanked divided by their post count and it works perfect.
I figure you just replace post_thanks_thanked_times with reputation here right? Hope this works, as I was getting the same type of output as you were until kh99 figured it out. Code:
if ($post['posts'] > 0) { $post['tip_ratio'] = vb_number_format($post['post_thanks_thanked_times'] / $post['posts'], 2); } else { $post['tip_ratio'] = '--'; // shouldn't ever happen, but protect against divide by 0. } So yes, the code I posted worked for me so it should be working for you too The Mailman ... |
#10
|
|||
|
|||
I did already. $post['posts'] is still not generating the actual post count, take a look at my above response explaining what's being output
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|