View Full Version : Posts Per Day in POSTBIT
maupassant
07-07-2013, 05:50 PM
Can someone tell me how to add Posts Per Day in POSTBIT, just under "Posts" ? I need to know the code and exactly where to put it in POSTBIT. Thanks.
Lynne
07-08-2013, 02:30 AM
Have you done a search for a mod that does this?
maupassant
07-12-2013, 01:27 AM
Yes I did. At vBulletin.com too. All the suggestions found are for vBulletin 3 only. And indeed I was able to display the info when we were with vBulletin 3. But not with vBulletin 4.
Lynne
07-12-2013, 03:36 AM
Did you try to convert the mod to vb4 at all? It should only be a matter of changing the template and template rendering, I would think. (I'm also surprised it doesn't already exist because I thought I saw it.)
Simon Lloyd
07-12-2013, 04:01 AM
I'm not up with rendering stuff in vb4 properly but you can use (untested) this kind of query and use the hook postbit_complete in a plugin$postdays = $vbulletin->db->query_read("SELECT joindate,posts FROM " . TABLE_PREFIX . "user WHERE userid = $post[userid]");
{
$mpostdays = $vbulletin->db->fetch_array($postdays);
$jd = time()-$mpostdays['joindate'];
$mpsts = $jd/$mpostdays['posts'];
echo $mpsts;
}
using $mpsts as the variable to show posts per day and of course you'll need a phrase for "Posts per day" (it already exists :))
CAG CheechDogg
07-12-2013, 10:45 AM
@ Simon - how about adding it to postbit_legacy?
Simon Lloyd
07-12-2013, 11:34 AM
It would be the same, you're simply using the variable $mpsts, like I said I don't know whether you can use that variable raw in vb4 or not (i'm sure Lynne will chip in :) (please!!)), also remember I haven't tested it, I just wrote it in notepad and plopped it in here :)
I should of also said you should use $mpsts = round($jd/$mpostdays['posts'];) (that shouldn't be a smiley it should be ; followed be ))
instead of $mpsts = $jd/$mpostdays['posts'];
maupassant
07-12-2013, 11:58 AM
Where do I put it in postbit_legacy ?
I hope you don't mind if I add a few suggestions: the post author's posts and joindate (joindateline) are already available, so you don't need a query. You could use the template hook postbit_userinfo_right_after_posts so that you don't need to edit the template. So maybe something like this (using postbit_display_complete):
if (($days = round((TIMENOW-$post['joindateline']) / 86400)) <= 0)
{
$days = 1;
}
$ppd = round($post['posts'] / $days, 2);
$template_hook['postbit_userinfo_right_after_posts'] .= "<dt>Posts Per Day</dt><dd>$ppd</dd>";
There is a phrase that says "Posts Per Day" but it isn't loaded for the showthread page, so if you need phrases or would rather use one, you'd have to load the 'user' phrases, or just create a new phrase using the 'postbit' phrase type.
Simon Lloyd
07-12-2013, 06:23 PM
Where do I put it in postbit_legacy ?It's a plugin so it doesn't go in a template
I hope you don't mind if I add a few suggestions: the post author's posts and joindate (joindateline) are already available, so you don't need a query. You could use the template hook postbit_userinfo_right_after_posts so that you don't need to edit the template. So maybe something like this (using postbit_display_complete):
if (($days = round((TIMENOW-$post['joindateline']) / 86400)) <= 0)
{
$days = 1;
}
$ppd = round($post['posts'] / $days, 2);
$template_hook['postbit_userinfo_right_after_posts'] .= "<dt>Posts Per Day</dt><dd>$ppd</dd>";
There is a phrase that says "Posts Per Day" but it isn't loaded for the showthread page, so if you need phrases or would rather use one, you'd have to load the 'user' phrases, or just create a new phrase using the 'postbit' phrase type.Hey Kevin, no problem, like I said I just knocked it up in notepad without checking anything else, yours is much better as there's no extra query :)
maupassant
07-12-2013, 07:38 PM
O.K. I have never added a new plugin before, but I think I understand what I need to do, except for one thing : "Execution Order : Use this field to enter the order in which code at the same hook will be executed". I notice a 5 already displayed by default. Do I leave the 5 there or do I change it for another number ?
maupassant
07-12-2013, 11:39 PM
O.k. I tried with "5".
Here are screenshots without the plugin and with the plugin. So not only do we not see the Posts Per Day but we are also losing the thanks given via the Post Thank You hack.
CAG CheechDogg
07-13-2013, 05:48 AM
Great thanks kh99 and Simon.
And maupassant , just create the plugin and activate it, you will see it take effect right away.
O.k. I tried with "5".
Here are screenshots without the plugin and with the plugin. So not only do we not see the Posts Per Day but we are also losing the thanks given via the Post Thank You hack.
That means there is something wrong with the plugin you're creating. I just tried the code again and it seems to work, so make sure what you're putting in the "Plugin PHP Code" box is exactly what I posted above.
Normally you would just leave the execution order at 5 as Cheech Dogg said, but in this case if you want the posts per day to come before the thanks, you could try a number lower than 5.
CAG CheechDogg
07-13-2013, 06:49 AM
I tried it with 1 through 5 and it displayed on all of them of course in different order.
Make sure the plugin is activated , by default the plugin is checked to not be active.
--------------- Added 1373702023 at 1373702023 ---------------
kh99 can I ask you here how I would display the total amount of new threads created every 24 hours in the forum stats?
I can start a new thread for that but it's in the stats family like this question and the OP might benefit from this stat display too.
Thank you ahead of time.
maupassant
07-13-2013, 05:54 PM
Oh, this is so weird. I tried it again kh99, and now it works, but the calculation of the PPD is way wrong. See here my own stats. My real PPD average is 32.84 and it says 0.03 in POSTBIT.
maupassant
07-13-2013, 06:03 PM
I'd like to try Simon LLoyd's plugin, but could someone please re-upload it with the correction he suggested (because I don't understand what he says I have to correct). Thanks to all, BTW.
Simon Lloyd
07-13-2013, 06:37 PM
Oh, this is so weird. I tried it again kh99, and now it works, but the calculation of the PPD is way wrong. See here my own stats. My real PPD average is 32.84 and it says 0.03 in POSTBIT.One of those states you have 35k posts and the other 15k???
maupassant
07-13-2013, 07:03 PM
53,004 posts in both pictures.
Simon Lloyd
07-13-2013, 07:25 PM
My apologies :)
here's mine with the round incorporated$postdays = $vbulletin->db->query_read("SELECT joindate,posts FROM " . TABLE_PREFIX . "user WHERE userid = $post[userid]");
{
$mpostdays = $vbulletin->db->fetch_array($postdays);
$jd = time()-$mpostdays['joindate'];
$mpsts = round($jd/$mpostdays['posts']/86400);
}You'll have to use KH99s use of hook to add it to the template or add $mpsts where you want the value to display. Remember I haven't tested this!!!
maupassant
07-13-2013, 09:09 PM
I probably didn't do this right. What I did is put your code in a new plugin using postbit_display_complete as hook location. And nothing new appears (no Posts Per Day).
My apologies :)
here's mine with the round incorporated$postdays = $vbulletin->db->query_read("SELECT joindate,posts FROM " . TABLE_PREFIX . "user WHERE userid = $post[userid]");
{
$mpostdays = $vbulletin->db->fetch_array($postdays);
$jd = time()-$mpostdays['joindate'];
$mpsts = round($jd/$mpostdays['posts']/86400);
}You'll have to use KH99s use of hook to add it to the template or add $mpsts where you want the value to display. Remember I haven't tested this!!!
CAG CheechDogg
07-14-2013, 04:11 AM
I get the same, didn't notice it yesterday but on some the Post Per Day = 0 and for some it reads out fine...
Simon Lloyd
07-14-2013, 08:04 AM
did you add $mpsts to your template? if I get time later on (got a lot of decking to build) i'll test it myself.
maupassant
07-14-2013, 10:57 AM
I have to add $mpsts in POSTBIT ? Where exactly ?
Simon Lloyd
07-14-2013, 11:48 AM
Wherever you want the value to show!, perhaps find where Posts: is already being displayed and add it under there, don't forget to add a phrase (or some text) for Posts per day and the html to have it on a new line..etc
I get the same, didn't notice it yesterday but on some the Post Per Day = 0 and for some it reads out fine...
That's strange. If you want to debug it, you could temporarily change the last line like:
$template_hook['postbit_userinfo_right_after_posts'] .= "<dt>Posts Per Day</dt><dd>$post[posts] $days $ppd</dd>";
Then see what the three numbers are. Is it possible that the number is so small it's rounding to 0?
maupassant
07-14-2013, 02:04 PM
What I get with your correction. The PPD is fine, but now it adds some odd numbers underneath (1615 0.03).
That's strange. If you want to debug it, you could temporarily change the last line like:
$template_hook['postbit_userinfo_right_after_posts'] .= "<dt>Posts Per Day</dt><dd>$post[posts] $days $ppd</dd>";
Then see what the three numbers are. Is it possible that the number is so small it's rounding to 0?
maupassant
07-14-2013, 02:13 PM
In this other profile, still with kh99's correction, the errors are different. The nb for Posts Per Day is wrong (it displays again the nb of posts instead). The real PPD here is 0.24 (displayed just below).
maupassant
07-14-2013, 02:17 PM
Wherever you want the value to show!, perhaps find where Posts: is already being displayed and add it under there, don't forget to add a phrase (or some text) for Posts per day and the html to have it on a new line..etc
I don't know how to do this. I have absolutely no notion about coding and programming. All I can do is add code and/or remove code where someone tells me to. But thanks for trying to help.
What I get with your correction. The PPD is fine, but now it adds some odd numbers underneath (1615 0.03).
That change was meant only for testing.
Simon Lloyd
07-14-2013, 05:05 PM
As Kevins mod shows the last 3 digits 0.03 would be $ppd or posts per day.
CAG CheechDogg
07-15-2013, 10:00 AM
That's strange. If you want to debug it, you could temporarily change the last line like:
$template_hook['postbit_userinfo_right_after_posts'] .= "<dt>Posts Per Day</dt><dd>$post[posts] $days $ppd</dd>";
Then see what the three numbers are. Is it possible that the number is so small it's rounding to 0?
I get the following kh99:
Posts Per Day : 9,624 4896 0
It is working because 9,624 / 4896 is the total post per day i am getting.....but it wont display it on the postbit_legacy...
Any thoughts?
--------------- Added 1373886774 at 1373886774 ---------------
I changed it to the following:
if (($days = round((TIMENOW-$post['joindateline']) / 86400)) <= 0)
{
$days = 1;
}
$ppd = round($post['posts'] / $days, 4);
$template_hook['postbit_userinfo_right_after_posts'] .= "<dt>Posts Per Day</dt><dd>$ppd</dd>";
and got :
Posts Per Day : 0.0018
instead of the 1.97 ......
--------------- Added 1373888531 at 1373888531 ---------------
So I have been told that because my total post count is 9,625, this plugin's code is interpreting the "," as an integer? So it has to be converted to a float so that it rounds of the number correctly since it has the "," in the number?
--------------- Added 1373925272 at 1373925272 ---------------
Any update on this you guys?
Sorry for the delay in getting back to this. I searched for it because someone else asked about the number being formatted with commas, and that is in fact why it's not working. But while looking in to that issue I found that posts per day is already calculated by the vb code, so you shouldn't need a plugin at all, you should just be able to add {vb:raw post.postsperday} to your template.
Simon Lloyd
08-02-2013, 07:45 PM
Good one!, i guess when i looked at it in the memberinfo template i thought it wouldn't be available in other templates but in vb3 using $post[postsperday] gave the correct value!
CAG CheechDogg
08-04-2013, 12:33 AM
Sorry for the delay in getting back to this. I searched for it because someone else asked about the number being formatted with commas, and that is in fact why it's not working. But while looking in to that issue I found that posts per day is already calculated by the vb code, so you shouldn't need a plugin at all, you should just be able to add {vb:raw posts.postsperday} to your template.
Still didn't work, it shows just the "Posts Per Day:" but not the stats ...
--------------- Added 1375581510 at 1375581510 ---------------
So I tried the following in postbit_legacy:
<div class="pbit"><div>Posts Per Day: {vb:raw prepared.postsperday}</div></div>
and
<div class="pbit"><div>Posts Per Day: {vb:raw posts.postsperday}</div></div>
After using the above, I still get nothing for the stats....just blank
Sorry, there was a typo. I think it should be {vb:raw post.postsperday}
CAG CheechDogg
08-04-2013, 01:36 AM
Sorry, there was a typo. I think it should be {vb:raw post.postsperday}
Awesome! You are the Man man ! Perfect, correct Posts Per Day results !
I used the following:
<dt>Posts Per Day</dt><dd>{vb:raw post.postsperday}</dd>
--------------- Added 1375584066 at 1375584066 ---------------
Hey! lol...it shows the stats for some and not for others....any ideas? lol....but it's working correctly...maybe a usergroup's permission?
--------------- Added 1375584454 at 1375584454 ---------------
Disregard kh99...I had it wrapped around a condition lol....*facepalm*....lol...sorry Bro...but thank you so much , once again you have been great help!
maupassant
08-10-2013, 08:18 PM
I added <dt>Posts Per Day</dt><dd>{vb:raw post.postsperday}</dd> in postbit_legacy and nothing happened. I don't see the Posts Per Day phrase, and I don't see the Posts Per Day stats either.
<vb:if condition="$post['joindate']"><dt>{vb:rawphrase join_date}</dt> <dd>{vb:raw post.joindate}</dd></vb:if>
<vb:if condition="$post['field2']"><dt>{vb:rawphrase location_perm}</dt> <dd>{vb:raw post.field2}</dd></vb:if>
<vb:if condition="$post['age']"><dt>{vb:rawphrase age}</dt> <dd>{vb:raw post.age}</dd></vb:if>
<dt>{vb:rawphrase posts}</dt> <dd>{vb:raw post.posts}</dd>
<dt>Posts Per Day</dt><dd>{vb:raw post.postsperday}</dd>
{vb:raw template_hook.postbit_userinfo_right_after_posts}
</dl>
<vb:if condition="$show['infraction'] OR $show['reppower']">
<dl class="user_rep">
<vb:if condition="$show['infraction']">
<dt>{vb:rawphrase infractions}</dt>
<dd>{vb:raw post.warnings}/{vb:raw post.infractions}
If you're not seeing "Posts Per Day" then either it's the wrong template or the wrong style. If you have your info across the top of the post (like this site) then you should edit postbit instead of postbit_legacy. Also make sure you're editing the same style you're using to view the forum.
maupassant
08-10-2013, 11:34 PM
If you're not seeing "Posts Per Day" then either it's the wrong template or the wrong style. If you have your info across the top of the post (like this site) then you should edit postbit instead of postbit_legacy. Also make sure you're editing the same style you're using to view the forum.
Many thanks ! I now added it in postbit and it works !
--------------- Added 1376182069 at 1376182069 ---------------
Let me know if I should start another thread for this, but I would like also to see this info displayed in each member's profile in the Admin Control Panel. Can it be done by adding the same code in the right template, and if so, what is the template I have to edit ?
Also, but I know I'm pushing my luck here, would it be possible to add this as a field in Search For Users - Advanced Search in the ACP : "Posts Per Day less than 0.15" ?
The admin control panel doesn't use templates, so you would need to modify the php files. But it could be done, of course.
maupassant
08-11-2013, 05:18 PM
Bummer. I'm admin of the site, but I don't own it and I don't have access to the php files. Well, thanks for your help anyway.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.