Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-04-2003, 03:21 AM
Boeman Boeman is offline
 
Join Date: Apr 2003
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom Global Variables

One of my external scripts referenced in PHPInclude requires the use of a global variable called $count_border to which it adds a count each time the script is called (it could be several times on a single page). I've tried inserting it into phpinclude, putting "global" before the variable and even adding it to the index.php file but to no affect. Is there a straightforward to do this with VB?

Thanks.
Reply With Quote
  #2  
Old 06-04-2003, 04:13 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the command global has to be used in the function which calls the script
Reply With Quote
  #3  
Old 06-04-2003, 04:32 PM
Boeman Boeman is offline
 
Join Date: Apr 2003
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 06:13 PM Xenon said this in Post #2
the command global has to be used in the function which calls the script

Does the PHP code contained in the external script have to be written as a fuction? At the moment it is a basic if statement.
Reply With Quote
  #4  
Old 06-04-2003, 04:50 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

no need for it to be a function, but if you call it from within a function you need to make vars global,n if you don't call it from within a function you also don't need to make the var global
Reply With Quote
  #5  
Old 06-04-2003, 06:06 PM
Boeman Boeman is offline
 
Join Date: Apr 2003
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 06:50 PM Xenon said this in Post #4
no need for it to be a function, but if you call it from within a function you need to make vars global,n if you don't call it from within a function you also don't need to make the var global

Well, it's actually an external script referenced in phpinclude and is called using the variable defined in phpinclude. I put the variable (in this case $forum_border) in formbit 1. All it needs to do is keep track of how many times it is called and based on that decides what action to take and then adds one to $border_count. So basically it is a variable within the external script that needs to be global. Maybe you have an example that spells it out for a php-impared man such as myself?
Reply With Quote
  #6  
Old 06-05-2003, 04:56 AM
Boeman Boeman is offline
 
Join Date: Apr 2003
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can anyone else help?
Reply With Quote
  #7  
Old 06-05-2003, 04:58 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

forumbit 1 is created in the makeforumbit FUNCTION of index.php so you have to globalize the var in that function.

but you won't see an effect, ast the forumbit is executed AFTER phpinclude, so your script won't show up the right value
Reply With Quote
  #8  
Old 06-05-2003, 05:04 AM
Boeman Boeman is offline
 
Join Date: Apr 2003
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 06:58 AM Xenon said this in Post #7
forumbit 1 is created in the makeforumbit FUNCTION of index.php so you have to globalize the var in that function.

but you won't see an effect, ast the forumbit is executed AFTER phpinclude, so your script won't show up the right value
Ah I see. So in other words there's no way I can keep an accurate counter variable with custom php code under the formbit templates?
Reply With Quote
  #9  
Old 06-05-2003, 05:19 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

there is a way, but it's not as easy as you tried to do it...
Reply With Quote
  #10  
Old 06-05-2003, 05:30 AM
Boeman Boeman is offline
 
Join Date: Apr 2003
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 07:19 AM Xenon said this in Post #9
there is a way, but it's not as easy as you tried to do it...
The script uses the counter only as a means of testing whether or not it was called for the first time with forumbit 1. If this is the first call go to option 1, if it has been called before go to option 2. Laid out like this:

If ($count_border < 1) {
Do this
} else {
Do this instead
}

I tried putting in $count_border variable as a global right after the line "return $forumbits;" as $count_border++; so it wouldn't equal 1 when forumbit is used next time. Of course it didn't work but implanting some kind of variable and altering its value right after the function is called so the external script would know the value has changed might just be all I need.

Would love to hear your ideas
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 01:43 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04197 seconds
  • Memory Usage 2,254KB
  • Queries Executed 13 (?)
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
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete