About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
legacy:vufind_1.x_developer_manual:global_variables

This is an old revision of the document!


Global Variables

:!: This page refers to VuFind 1.x; newer versions of VuFind do not rely on global variables at all.

VuFind uses a few important global variables that you may find helpful when building modules and maintaining the code.

Primary Globals

These two globals are the most important, and their use is encouraged:

  • $configArray
    This global contains the contents of the web/conf/config.ini file mapped into associative array format.
  • $interface
    This global is an instance of the UInterface class, used for passing information to the Smarty presentation layer. See the System Classes page for more details.

Secondary Globals

These globals are used in the code in a few places, but their use should be avoided unless absolutely necessary:

  • $translator
    This global is an instance of the I18N_Translator class, used for translating presentation-layer text into various languages. This should be needed only rarely outside of the presentation templates.
  • $user
    This global is an object representing the current logged-in user, if one exists. User login code may be refactored, so use this sparingly.

Accessing a Global

Remember that in PHP, you need to declare globals at the top of any functions or methods that use them. For example:

function dumpConfigArray() 
{
    global $configArray;
 
    print_r($configArray);
}
legacy/vufind_1.x_developer_manual/global_variables.1449771678.txt.gz · Last modified: 2015/12/10 18:21 by demiankatz