Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-05-2004, 07:23 PM
misterfade misterfade is offline
 
Join Date: Jun 2003
Location: MTL
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 08-11-2004, 04:15 PM
misterfade misterfade is offline
 
Join Date: Jun 2003
Location: MTL
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone?? Nobody?
Reply With Quote
  #3  
Old 08-11-2004, 04:27 PM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']);
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:
Code:
$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.
Reply With Quote
  #4  
Old 08-12-2004, 12:53 PM
misterfade misterfade is offline
 
Join Date: Jun 2003
Location: MTL
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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";
?>
When I put the include before $userstats and $numbermembers, I get this error:
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
Anyway, but now I get this error:
Code:
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...
Reply With Quote
  #5  
Old 08-12-2004, 01:22 PM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 08-12-2004, 05:09 PM
misterfade misterfade is offline
 
Join Date: Jun 2003
Location: MTL
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:44 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03944 seconds
  • Memory Usage 2,205KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete