PDA

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


LanciaStratos
26 Nov 2007, 05:16
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
26 Nov 2007, 15:41
Put this code in a plugin on the postbit_display_complete hook


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



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
28 Nov 2007, 04:51
Ah, OK, sucks about the evaluation order of the footer template. Thanks anyway, AP!