vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Get current amount of posts shown on a page (https://vborg.vbsupport.ru/showthread.php?t=271475)

benFF 10-05-2011 01:24 PM

Get current amount of posts shown on a page
 
I'm working on a conditional which runs in the "global_start" hook which sets up adverts for the page.

One of the things I am doing, push advert banner data into the ad_location_showthread_afterqr template, but ONLY if there are more than 2 replies shown on the page.

The code:
PHP Code:

if ($GLOBALS[threadinfo][replycount] >= 2

Works fine as long as there is only one page of posts, however, if on page 2, 3, 4 etc - then the value is always true, so it doesn't work as I need.

As I don't have access to the $post parameter at that time, I can't do a count (can I?) so does anyone know the code I need?

Psuedo like:

If more than 2 replies shown on THIS page, then set X=Y

Thanks!

kh99 10-05-2011 05:40 PM

Is ad_location_showthread_afterqr a template you added? Where is is being used? If it's in the SHOWTHREAD template then you can probably move your plugin to showthread_complete and use $counter as a count of the posts on the page.

benFF 10-06-2011 03:00 AM

Lol, sorry I totally got that wrong - it's the ad_showthread_beforeqr template (the one built in).

I can't move the plugin though, as it's a single one which works out all the advert banners for the page (be it a show thread or not).

Actually, that's not true - *ideally* I don't want to be chopping it all up - but if there is no other way, then so be it.

Although - if the $counter variable is always there, then it could be used in a conditional in the template itself?

kh99 10-06-2011 05:27 AM

Quote:

Originally Posted by benFF (Post 2253819)
Although - if the $counter variable is always there, then it could be used in a conditional in the template itself?

The problem is that when the global_start hook code is executed, $counter won't have been set yet. You might be able to look at the page and perpage variables and figure out how many replies will be on the current page (you should be able to figure that out from looking at code in showthread.php).


All times are GMT. The time now is 10:10 AM.

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.01145 seconds
  • Memory Usage 1,719KB
  • 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_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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