The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
Hi,
I'm using vB 3.6.8 patch level 2. I want to add variables for use in any and all templates. To do so, I've created a mytxtfile.txt file with the desired content (in HTML), and added the following lines at the end of global.php: $mytxtfile = 'mytxtfile.txt'; $mycontent = file_get_contents($mytxtfile); Then, I added $mycontent inside templates, by writing $mycontent in the template editor. The problem is that this works with some templates, but not with others. For example, it worked with navbar and with a new template I made, but not with postbit. 1. Why? 2. Is there a better way to do this? 3. Where are custom templates (like the new one I made) stored? Any help will be appreciated, Thank you, R. |
#2
|
|||
|
|||
![]()
Add the following line to your plugin:
PHP Code:
|
#3
|
|||
|
|||
![]()
First, thank you. Now, I'm a total newbie. Where is my plugin (do I even have one?) and how do I add this line to it?
|
#4
|
|||
|
|||
![]()
Hmm now see that you don't use a plugin but instead edit global.php (bad choice in my view). Just add it in global.php then, just above the 2 lines you already added.
|
#5
|
|||
|
|||
![]()
Thank you again, Marco.
- Is the global command a vB function? - What is the better way to do this, in your experience? |
#6
|
|||
|
|||
![]()
"global" is a standard PHP command that will set the variable in the global scope.
I would not do any code edits, but just put this code into a plugin, probably using the 'global_start' hook location. |
#7
|
|||
|
|||
![]()
I've tried this - but it still doesn't work with the postbit template. Why could that be?
Quote:
To anyone who's had the same type of problem, I've found a different solution. I am ignorant as to why this worked and the other way didn't, but here it is: Instead of referencing $mycontent directly, I called it through $GLOBALS, which is a superglobal. It is an array of all global-scope variables, the keys of which are the variables' names. Therefore, I was able to call $mycontent by writing $GLOBALS[mycontent]. This page helped me find this solution. |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|