Welcome to Majicko.com

Search



Main Menu

Calendar

September '10
S M T W T F S
   1234
567891011
12131415161718
19202122232425
2627282930  

Site Styles

Latest News

Majicko.com
FAQS

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.

Powered by Majicko1.3.0! ©2008 Bandwise LLC