Log in

View Full Version : $totalposts in header template


Ghostt
01-24-2012, 03:34 AM
hi,
a noob question.
how can i display $totalposts in the header template?
thx

kh99
01-24-2012, 05:45 PM
You could try this, using hook parse_templates:

$totalthreads = 0;
if (is_array($vbulletin->forumcache))
{
foreach ($vbulletin->forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
}
}
$totalthreads = vb_number_format($totalthreads);


but to be honest I'm not sure if it will work on every page (or at all - I haven't tested it).

Ghostt
05-16-2014, 02:34 AM
hi, its dosent working. it shows 0.
i saw your post here: https://vborg.vbsupport.ru/showthread.php?t=294099&highlight=%24totalposts+%24totalthreads

and here is to much other stuff and dont know if it makes querys: http://www.vbulletin.com/forum/forum/vbulletin-4/vbulletin-4-questions-problems-and-troubleshooting/355712-how-to-display-stats-from-what-s-going-on-in-header?p=3074564#post3074564


is it possible for vb 3 but its important to not have querys?

kh99
05-16-2014, 08:13 AM
lol, that was a long time ago, and I just noticed that you asked about $totalposts and I gave you code that calculates total threads. If you were trying $totalposts in your template, then try this:
if (is_array($vbulletin->forumcache))
{
$totalposts = 0;
foreach ($vbulletin->forumcache AS $forum)
{
$totalposts += $forum['replycount'];
}
}
$totalposts = vb_number_format($totalposts);

Ghostt
05-16-2014, 11:16 PM
ive tested with both. your code didnt work. also tested with original vb plug-in code