|
|
Search
Main Menu
Calendar
|
September '10
|
| S |
M |
T |
W |
T |
F |
S |
| | | 1 | 2 | 3 | 4 | | 5 | 6 | 7 | 8 | 9 | 10 | 11 | | 12 | 13 | 14 | 15 | 16 | 17 | 18 | | 19 | 20 | 21 | 22 | 23 | 24 | 25 | | 26 | 27 | 28 | 29 | 30 | | |
Site Styles
Latest News
|
Frequently Asked Questions
I wrote a custom function, but my phrases are not working. Am I doing something wrong?
The phrases used throughout Majicko are stored in your database and cached in the global.php file every time a new page is loaded. The array you want access to in your script is $maj_phrase which is where all of the phrases are cached. The keys in the array are the names for each phrase that you selected in the admin panel (i.e. $maj_phrase['my_custom_text']).
If you've used PHP for a while, you'll note that PHP functions are stand-alone. No variables or arrays defined outside of the function are accessible unless you either pass the variable through the function as a parameter (or arguement in some programming languages) or you globalize it.
In short, you can get your phrases by doing this at the top of your function:
function my_function() { global $maj_phrase; // This globalizes the variable for you
return $string; }
That's all there is to it. If you want to access Majicko's settings, user login data, or phrases, they are all accessible inside functions, but you must globalize them first. You can get all three arrays into your function with this line:
global $majicko, $maj_settings, $maj_phrase;
This brings in your user data, system settings, and phrases all in one line. This may be less awkward for you. Now you can use each of them freely as if you were not inside of a function.
|