The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
![]()
Hi, I would like to ask:
How to display total posts & members in header/navbar? Example: I tried to use the code below (taken from forumhome -> stats) but seems not working: Code:
<div> $vbphrase[threads]: $totalthreads, $vbphrase[posts]: $totalposts, $vbphrase[members]: $numbermembers<if condition="$show['activemembers']">, <span title="<phrase 1="$vboptions[activememberdays]">$vbphrase[within_the_last_x_days]</phrase>">$vbphrase[active_members]: $activemembers</span> </if> </div> Thank you and I hope to hear a good response from you soon. |
#2
|
||||
|
||||
![]()
Those values are only calculated on the forum index (forumhome) page so on any other page they will all be blank.
If you want to put them in your navbar you'll need to make a new plugin do do those queries on each page and display their output- you'll also want to rename the variables so you don't conflict with the existing variable names. |
#3
|
||||
|
||||
![]()
Can you make one for me? I'm willing to offer you a paid service for this if you wish, just PM me your query
![]() |
#4
|
||||
|
||||
![]()
Sorry, I tried working on this for a while... I found some suggestions in this thread:
https://vborg.vbsupport.ru/showthread.php?t=77916 But nothing I tried worked. ![]() |
#5
|
||||
|
||||
![]()
Thank you for your reference, m8.. Let's get it worked
![]() |
#6
|
|||
|
|||
![]()
I think this works:
Code:
cache_ordered_forums(1, 1); $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); For the total members you could do a query: Code:
$members = $vbulletin->db->query_first("SELECT COUNT(*) AS users FROM " . TABLE_PREFIX . "user"); $numbermembers = $members['users']; The value is in the datastore but to get it you'd have to add userstats to $specialtemplates before including global.php (like is mentioned at the link BOP5 posted above), but that would mean editing the file for every page you wanted it to appear on, or maybe putting it in init.php (although I'm not sure what other issues that might cause). |
#7
|
||||
|
||||
![]()
kh99 was spot on as usual.
To put this all together go to your Admin CP -> plugin manager -> add new plugin product: vBulletin hook: global_start title: Stats on Navbar Execution Order: 5 php code: PHP Code:
Then in your navbar you can use $bopposts, $bopthreads, and $bopmembers which will hold the number os posts, threads, and members respectfully. Note however this adds extra queries to your pages but there's no other way to get this info if you want it on every page. |
#8
|
|||
|
|||
![]()
Actuall I have to take that back: it *is* called in forumdisplay, and if you're using the original index.php it's called there as well. So on a busy site where you're worried about every query, you may want to be careful about using this.
|
#10
|
||||
|
||||
![]()
You can use the $bop variables just fine... if you use just $threads and $posts and such it might interfere with other mods or regular board functions, it's just a good idea to use unique names.
|
![]() |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|