The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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. |
#2
|
||||
|
||||
the command global has to be used in the function which calls the script
|
#3
|
|||
|
|||
Quote:
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. |
#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
|
#5
|
|||
|
|||
Quote:
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? |
#6
|
|||
|
|||
can anyone else help?
|
#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 |
#8
|
|||
|
|||
Quote:
|
#9
|
||||
|
||||
there is a way, but it's not as easy as you tried to do it...
|
#10
|
|||
|
|||
Quote:
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 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|