The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Total number of members on a non-vb page?
Hi,
I've been trying to display the total number of registered members of my forum on a non-vb page but I can't seem to get it to work. I've include global.php at the top of my page, and calling $numbermembers but of course it doesn't work. If anyone can help me out it would be appreciated. Thanks. |
#2
|
|||
|
|||
Anyone?? Nobody?
|
#3
|
|||
|
|||
Likely you saw the reference to $numbermembers in index.php, but that variable would only be available to index.php. If you want a similar value outside of that script, you have to replicate what index.php is doing.
(The only time that a variable like $numbermembers actually contains anything is when some PHP code sets it while it is running to build the current page. In this case, index.php does not run except when building that specific page. Also, just including global.php does not set every variable you might see in vB -- it only sets a certain number of core variables used by most scripts.) The first stab at this would lead one to insert this code: Code:
$userstats = unserialize($datastore['userstats']); $numbermembers = vb_number_format($userstats['numbermembers']); Code:
$specialtemplates = array( 'userstats', So, in order for it to work in your file, you would need this code... At the top of your file before including global.php, add userstats to the $specialtemplates array or if you did not specify any values for specialtemplates, set it as follows: $specialtemplates = array('userstats'); then you can after the include of global.php, the two lines to set $numbermembers. |
#4
|
|||
|
|||
Hi, thanks for the reply!
I tried what you said, and I put it like this: Code:
<?php $specialtemplates = array('userstats'); $userstats = unserialize($datastore['userstats']); $numbermembers = vb_number_format($userstats['numbermembers']); include "forums/global.php"; ?> Code:
Warning: main(./includes/init.php): failed to open stream: No such file or directory in /forums/global.php on line 18 Fatal error: main(): Failed opening required './includes/init.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /forums/global.php on line 18 Code:
Fatal error: Call to undefined function: vb_number_format() in test3.php on line 4 |
#5
|
|||
|
|||
You must put the code suggested in a proper vB script that, among other things, requires global.php in the proper location. Look at one of the scripts in the upload directory for examples -- index.php is one such script. I assumed that you already had such a script and I was suggesting you *add* the code to it.
|
#6
|
|||
|
|||
No, I don't have a script already, I'm just trying to add some code to my regular php pages that will display the total number of members on most of my pages outside of vbulletin. Any suggestions?
Thx. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|