Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: counting forums


_ck_
Participant

@_ck_

update: there is a better version a few posts down

I had worked this out this quick and dirty routine but then I realized you might mean not to show it within the forum list. If you mean something different let me know.

In front-page.php

Change

<?php  while ( bb_forum() ) :  ?>

to

<?php
forum_totals("init");
while ( bb_forum() ) :
forum_totals();
?>

and then this after the end of the forum list routine

<?php  endwhile;  ?>

to this

<?php
endwhile;
forum_totals("finish");
?>

This is the main function you can just drop at the bottom of front-page.php

<?php
function forum_totals($x="") {
static $last_parent,$total_posts,$total_topics,$all_topics,$all_posts,$total_counter,$all_counter;
if (function_exists('bb_get_forum_is_category')) {$category=bb_get_forum_is_category();} else {$category=false;}
if ($x=="init") {$last_parent=false; $total_topics=0; $total_posts=0; $all_topics=0; $all_posts=0; $total_counter=0; $all_counter=0; return;}
if ($x=="finish" || $last_parent!==$GLOBALS['forum']->forum_parent || $category) {
if ($last_parent!==false && $total_counter>1) {echo "<tr><td align='right'>$total_counter subforums:</td><td class='num'>$total_topics</td><td class='num'>$total_posts</td></tr>";}
$last_parent=$GLOBALS['forum']->forum_parent; $total_topics=$GLOBALS['forum']->topics; $total_posts=$GLOBALS['forum']->posts;
$total_counter=0;
} else {$total_topics+= (int) $GLOBALS['forum']->topics; $total_posts+=(int) $GLOBALS['forum']->posts;}
$all_topics+= (int) $GLOBALS['forum']->topics; $all_posts+=(int) $GLOBALS['forum']->posts;
if ($x=="finish") {echo "<tr><td align='right'>$all_counter total forums:</td><td class='num'>$all_topics</td><td class='num'>$all_posts</td></tr>";}
elseif ($category) {$last_parent=false;} else {$all_counter++; $total_counter++; }
}
?>

Skip to toolbar