PDA

View Full Version : Better alternative to reply count?


xlguy
11-26-2013, 10:48 PM
Hi,

I'm currently using

<if condition="$GLOBALS[threadinfo][replycount] >= 2">

I use this to show an ad in SHOWTHREAD if there thread has more than 2 replies. This works fine on the first page, but when the thread goes on to the 2nd page, and initially you only have 1 post, it's showing the ad - because although there is only 1 post on this page, there are 10+ posts in this thread total and therefore the conditional above is TRUE.

Is there a conditional I could use that would avoid this, i.e one that could consider how many posts are actually showing on the current page in a showthread?

tbworld
11-26-2013, 11:34 PM
Off the top of my head, you going to need the $perpage variable on showthread, which is already registered to the template. Obviously, you will need to divide ($threadinfo[resultcount] / $perpage) and handle it correctly, but I have not looked at the code as of yet. When I get a chance I will do so.


// Hook: postbit_display_complete
// Settings->Options->Thread Display Options (showthread)->Maximum Displayed Posts Before Page Split.
//
// Use the following variable for your condition in your selected postbit template.
// The following variable contains an on-going post count from the page query.
// {vb:raw tb_postbit_postcount}

if (THIS_SCRIPT == 'showthread')
{
global $tb_postbit_postcount;
vB_Template::preRegister('postbit_legacy',array('t b_postbit_postcount' => ++$tb_postbit_postcount));
}
You will need to do some tests on this, but it should work. Now you can place an ad on post two and on post six, per page. Have fun. :)

xlguy
11-27-2013, 12:44 PM
Thanks a lot for that :)