Magic Words
A Guide to Using MediaWiki in a Hosted Environment
An instructional website by the developer of mh370wiki.net - a MediaWiki site about Malaysia Airlines Flight MH370.
Magic words are strings of text that MediaWiki associates with a return value or function, such as time, site details, or page names.
There are three general types of magic words:
- Behavior switches: these are usually written as uppercase words surrounded by double underscores, e.g.
__FOO__. - Variables: these are uppercase words surrounded by double braces, e.g.
{{FOO}}. As such, they look a lot like templates. - Parser functions: these take parameters and are either of the form
{{foo:...}}or{{#foo:...}}, e.g.{{#invoke:...}}. See also Help:Extension:ParserFunctions and Extension:Scribunto.
Source: MediaWiki Help:Magic words
This page focusses on magic words used as behaviour switches. Separate articles focus on Variables and Parser Functions.
Magic Words as Behaviour Switches
Table of Contents
MediaWiki automatically generates a Table of Contents (TOC) when more than three section headings are used on a page.
This behaviour can be controlled on a per-page basis using magic words:-
| Magic Word | Behaviour | Main Article |
|---|---|---|
__NOTOC__ |
Hides the Table of Contents | Table of Contents |
__TOC__ |
The Table of Contents is positioned wherever this magic word is placed. | |
__FORCETOC__ |
Forces the Table of Contents to appear at its normal position (before the first header, overriding __NOTOC__) |
Tooltips
The Extension:Lingo creates a glossary which is used to add tooltips to all pages.
However, if the magic word __NOGLOSSARY__ is placed anywhere in a page it will exclude the article and tooltips will not be displayed.
Hidden Categories
If the magic word __HIDDENCAT__ is added to a Category page, the category and it's sub-categories will not be listed.
Robot Policy
Robot policies are configured using a robots.txt file and/or variables in LocalSettings.php, and can be applied globally or by namespace.
The indexing preference can be changed on a per-page basis using magic words __INDEX__ or __NOINDEX__. The magic word is intended to over-ride global namespace policy but the Manual:NoIndex describes methods to test if it actually works.
Other Uses
The above examples of magic words are perhaps the most commonly used behaviour switches, but there are others. Please refer to the documentation Help:Magic words.
Links
- Help:Magic words
- https://www.mediawiki.org/wiki/Help:Magic_words