PDA

View Full Version : Counting the number of posts displayed on a page?


LanciaStratos
11-26-2007, 03:16 AM
OK, I've got a right column down the side of my forum pages, the code of which is contained in my footer template. When viewing a thread, I'd like to have access to a variable that contains the number of posts being displayed on that particular page. I know that $post[postcount] obviously exists within the scope of postbit, but that's not exactly what I want nor is it usable from within the footer template. Is there another way to accomplish this that I haven't yet thought of? Any simple way to modify the source code?

(Why do I want to do this? Basically, I want to show more advertisements in the right hand column as the number of posts on the page increase. These obviously extend the page downward and I would love to take advantage of that otherwise wasted real estate.)

Analogpoint
11-26-2007, 01:41 PM
Put this code in a plugin on the postbit_display_complete hook
$GLOBALS['pagepostcount'] = $post['postcount'];

Then in templates, use $GLOBALS['pagepostcount'] to reference it. But I may as well warn you that you won't be able to use it in the footer template, since the footer template is evaluated before the posts are displayed.

LanciaStratos
11-28-2007, 02:51 AM
Ah, OK, sucks about the evaluation order of the footer template. Thanks anyway, AP!