PDA

View Full Version : Forum stats in header template


DionDev
07-14-2009, 02:05 AM
This makes no sense. Why is something so simple being so difficult?

Adding the following code as a plugin in global_start does not work:


// ### BOARD STATISTICS #################################################

// get total threads & posts from the forumcache
$totalthreads = 0;
$totalposts = 0;
if (is_array($vbulletin->forumcache))
{
foreach ($vbulletin->forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);

// get total members and newest member from template
$numbermembers = vb_number_format($vbulletin->userstats['numbermembers']);
$newusername = $vbulletin->userstats['newusername'];
$newuserid = $vbulletin->userstats['newuserid'];
$activemembers = vb_number_format($vbulletin->userstats['activemembers']);
$show['activemembers'] = ($vbulletin->options['activememberdays'] > 0 AND ($vbulletin->options['activememberoptions'] & 2)) ? true : false;


When using the variable $totalthreads in the header template after creating and activating this plugin, it is still not showing the $totalthreads count in the header where I want it to.

I have not seen a suitable fix for this. And no, a mod that executes 6 queries just to pull up these cached statistics is not what I am looking for.

HMBeaty
07-14-2009, 02:15 AM
just a small bit from one of my custom files on my site.....it should help you out a bit:
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR. '/includes/functions.php');
require_once(DIR. '/includes/functions_forumlist.php');
cache_ordered_forums(1);

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

// ### BOARD STATISTICS #################################################

// get total threads & posts from the forumcache
$totalthreads = 0;
$totalposts = 0;
if (is_array($vbulletin->forumcache))
{
foreach ($vbulletin->forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);

--------------- Added 1247541532 at 1247541532 ---------------

Actually....looking at that again, that IS part of my file. You're just missing the require_once variables I believe