Manual:Hooks/MagicWordwgVariableIDs

Details
A variable is a string of the form. It is effectively a hardcoded, parameter-less template. MediaWiki provides several built-in variables. With this hook you can also define custom variables for your mediawiki installation.

Defining variables requires a four step process:
 * 1) Choose a magic word id for your variable.  This is only an internal identifier that is used to tie together the various parts of the variable definition: the names that appear in wiki text, and the php code that assigns a value to the variable.
 * 2) Define the names that will appear in wiki text. To accomplish this, you will need to define and register a hook function with LanguageGetMagic.  Your hook function will be passed an array and the hook function will add an entry whose key is the internal magic word id and whose value is an array containing all the names you want to use for your variable.  Your names can be case sensitive and language dependent.  See LanguageGetMagic for more information.
 * 3) Declare the magic word id as a variable.  To accomplish this we write and assign a hook to , the subject of this article.  Note: this hook is only for use with variables. Do not use it to define parser functions.
 * 4) Provide php code to assign a value to the variable.  To accomplish this, you will need to define and register a hook function with Manual:Hooks/ParserGetVariableValueSwitch.

Usage
Usage is best explained by an example:

''Note: if you wish to use this example as a coding template, please replace  with something unique to your project so that there is less risk of name clashes with MediaWiki or any of its extensions. For example, if your extension was named  and you were reasonably sure that no-one else had an extension with constants, variables, functions, or classes beginning 'BEST_', 'wgBEST', 'wfBEST', or even 'BEST' you might want to replace 'My' with 'BEST'.''

For more information

 * Manual:Magic words - reviews the different kinds of magic words
 * Extension:Variables - another example of code that uses this hook