The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
totalposts in header
hi,
how can i display {vb: totalposts} in the header template? ty --------------- Added [DATE]1358591472[/DATE] at [TIME]1358591472[/TIME] --------------- ???? |
#2
|
|||
|
|||
Try this: create a new plugin using hook parse_template and this code:
Code:
global $vbulletin; $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); vB_Template::preRegister('header', array('totalthreads' => $totalthreads, 'totalposts' => $totalposts)); Then you should be able to use {vb:raw totalposts} in the header (I know you didn't ask for totalthreads, but it was there so I thought I'd just leave it). |
#3
|
|||
|
|||
It only works that I found in ForumHOME but when I entered the forum everything turns to 0 ...
And how to do it too to totalonline? --------------- Added [DATE]1358688103[/DATE] at [TIME]1358688103[/TIME] --------------- ??? |
#4
|
|||
|
|||
???
|
#5
|
|||
|
|||
You're right, it doesn't work on all pages because the information isn't always in the forum cache. Sorry, my mistake. You could change the code to something like this:
Code:
global $vbulletin; $totalthreads = 0; $totalposts = 0; if (is_array($vbulletin->forumcache)) { foreach ($vbulletin->forumcache AS $forum) { $totalthreads += $forum['threadcount']; $totalposts += $forum['replycount']; } } if ($totalthreads == 0) { $result = $vbulletin->db->query_first_slave("SELECT SUM(threadcount) AS threadcount, SUM(replycount) AS replycount FROM " . TABLE_PREFIX . "forum"); if (!empty($result)) { $totalthreads = $result['threadcount']; $totalposts = $result['replycount']; } } $totalthreads = vb_number_format($totalthreads); $totalposts = vb_number_format($totalposts); vB_Template::preRegister('header', array('totalthreads' => $totalthreads, 'totalposts' => $totalposts)); but you should be aware that this will add a query to each page that didn't already have the information, which could be significant if your forum is busy. It would be better to set something up to cache the information periodically, but that's a little more complicated. |
Благодарность от: | ||
glennybee |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|