I would think this is to be declared somewhere in index.php in the main forum directory ? But i have tried it and it does not work.
Lets say i want to use the variable $somevar = 'somevalue'; in Boardindex.php and somewhere else in index.template.php and maybe later as well at other places ...
I want to add my own variable that can be called upon anywhere in the script.
Thanks in advance for helping me out.
Depends what type of variable?
You can stick it in settings.php
Then use it as a global
global $variablename;
echo $variablename;
Or add it to the $context array - or, if it is user specific, add it to the $user_info array
Its a variable that i also use in the non smf parts of the website. So just a normal variable please. No global. No array. Just a casual variable containing a simple string.
I ll be a little more specific maybe
In my own script of the website where smf forum is part of i have this header.php file.
The file loads no matter what page you are visiting.
In this file i have this written on top of it ...
include 'includes/variables.php';
In the variables.php file are some variables declared that can be called upon on any page.
Now i want to be able to use that same variables inside the smf script. This means i am looking for the part where i must ad include '../includes/variables.php; so that i can call upon the same variables also inside the smf script.
You will still need to globalize the variable if you plan to use it anywhere outside of the specific header
Not if i include the variables.php file somewhere on top of any smf page that might be loaded
Is there no place in the smf script that gets loaded no matter what page is builth/requested/loaded ? Because that is the only information i actually need.
Yes, even if you include the variable.php file...
If you plan to use the variables inside of SMF functions, they will need to be globalized.
Indeed i overlooked i was working inside a function when including the variables file. Problem solved. Working perfect now. Thanks for your replies.