Quote:
Originally Posted by radiofranky
how to show total threads in HEADER template?
|
The variable $totalthreads is registered in the FORUMHOME template to show that value. But registering that variable in the header template won't work because the value is only calculated in the forum.php script, so if you are on any other page it will be blank. The only way to do it would be to create a plugin that calculates the value, and use a hook that will calculate it on every page.
Edit: Your plugin code could be something like (and parse_templates is probably a good hook to use):
PHP Code:
$tt = $vbulletin->db->query_first("SELECT SUM(threadcount) AS totalthreads FROM " . TABLE_PREFIX . "forum");
$total = $tt['totalthreads'];
vB_Template::preRegister('header', array('totalthreads' => $total));
unset($tt, $total);
and then put {vb:raw totalthreads} in header template where you want it.
This adds a query to every page, and it's always good to reduce the number of queries to speed up your site, but it's probably not a big deal. You could cache the value in the datastore, but that's a more advanced topic.