vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Better alternative to reply count? (https://vborg.vbsupport.ru/showthread.php?t=305071)

xlguy 11-26-2013 10:48 PM

Better alternative to reply count?
 
Hi,

I'm currently using

PHP Code:

<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.

Code:

// 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('tb_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 :)


All times are GMT. The time now is 03:39 PM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01053 seconds
  • Memory Usage 1,716KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete