I've set up a custom vb page, on this page I like to show, basically the same stats block as on forumhome. Got most of it working by checking forum.php, but 'totalposts' and 'totalthreads' only show 0 (zeros). What am I missing?
My custom page code:
PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'wp-ext');
define('CSRF_PROTECTION', true);
// change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array(
'userstats',
'activeblocks',
);
// pre-cache templates used by all actions
$globaltemplates = array('wp-ext',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$navbits = construct_navbits(array('' => 'To WP Ext'));
$navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'WP Ext';
// ### 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']);
$newuserinfo = array(
'userid' => $vbulletin->userstats['newuserid'],
'username' => $vbulletin->userstats['newusername']
);
$activemembers = vb_number_format($vbulletin->userstats['activemembers']);
$show['activemembers'] = ($vbulletin->options['activememberdays'] > 0 AND ($vbulletin->options['activememberoptions'] & 2)) ? true : false;
$ad_location['board_after_forums'] = vB_Template::create('ad_board_after_forums')->render();
$ad_location['board_below_whats_going_on'] = vB_Template::create('ad_board_below_whats_going_on')->render();
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('wp-ext');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('activemembers', $activemembers);
$templater->register('activeusers', $activeusers);
$templater->register('ad_location', $ad_location);
$templater->register('newuserinfo', $newuserinfo);
$templater->register('numberregistered', $numberregistered);
$templater->register('numbermembers', $numbermembers);
$templater->register('template_hook', $template_hook);
$templater->register('totalposts', $totalposts);
$templater->register('totalthreads', $totalthreads);
print_output($templater->render());
?>
I'm trying to fetch the totals with
Code:
{vb:raw totalthreads}
{vb:raw totalposts}
Any suggestions?