PDA

View Full Version : Total number of members on a non-vb page?


misterfade
08-05-2004, 07:23 PM
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.

misterfade
08-11-2004, 04:15 PM
Anyone?? Nobody?

CarCdr
08-11-2004, 04:27 PM
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:$userstats = unserialize($datastore['userstats']);
$numbermembers = vb_number_format($userstats['numbermembers']);
but that won't do it because of the way vB deals with the $datastore[] array. If you search index.php for other references to userstats, you will find this reference:$specialtemplates = array(
'userstats',

which tells global.php's included init.php file to make the $datastore['userstats'] available.
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.

misterfade
08-12-2004, 12:53 PM
Hi, thanks for the reply!

I tried what you said, and I put it like this:


<?php
$specialtemplates = array('userstats');
$userstats = unserialize($datastore['userstats']);
$numbermembers = vb_number_format($userstats['numbermembers']);
include "forums/global.php";
?>


When I put the include before $userstats and $numbermembers, I get this error:

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


Anyway, but now I get this error:

Fatal error: Call to undefined function: vb_number_format() in test3.php on line 4


Can you tell me what I'm doing wrong here? And thanks for the help...

CarCdr
08-12-2004, 01:22 PM
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.

misterfade
08-12-2004, 05:09 PM
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.