Extensions FAQ: Difference between revisions
preparation for translation |
m Protected "Extensions FAQ": Excessive vandalism ([Edit=Allow only autoconfirmed users] (expires 08:39, 3 January 2027 (UTC)) [Move=Allow only autoconfirmed users] (expires 08:39, 3 January 2027 (UTC))) |
||
| (22 intermediate revisions by 11 users not shown) | |||
| Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
| ⚫ | |||
[[File:MediaWiki-extensions-icon.svg|125px|alt=<translate><!--T:1--> MediaWiki extensions</translate>|right]] |
[[File:MediaWiki-extensions-icon.svg|125px|alt=<translate><!--T:1--> MediaWiki extensions</translate>|right]] |
||
| Line 11: | Line 12: | ||
==How do I enable an extension?== <!--T:3--> |
==How do I enable an extension?== <!--T:3--> |
||
</translate> |
</translate> |
||
<translate><!--T:38--> For most extensions, copy the extension PHP file (or directory) to your <tvar name="1"><code>extensions/</code></tvar> folder and add the following statement to your <tvar name="2"><code>{{ll|Manual:LocalSettings.php|LocalSettings.php}}</code></tvar>, with <code>ExtensionName</code> being the filename of your extension, such as ''MyExtension.php''.</translate> |
|||
See [[Manual:Extensions/Installation and upgrade]] |
|||
<syntaxhighlight lang="php"> |
|||
require_once "extensions/ExtensionName/ExtensionName.php"; |
|||
</syntaxhighlight> |
|||
| ⚫ | |||
<translate><!--T:39--> Since <tvar name=1>{{ll|MediaWiki 1.25|1.25}}</tvar> (2015), there is a new way of installing extensions, which works with extensions that support [[<tvar name=2>Special:MyLanguage/Manual:Extensions</tvar>|extension registration]].</translate> |
|||
<translate><!--T:4--> The equivalent for the extension above would be:</translate> |
|||
<syntaxhighlight lang="php"> |
|||
wfLoadExtension('ExtensionName'); |
|||
</syntaxhighlight> |
|||
<translate><!--T:5--> Some extensions, however, have additional steps and/or different installation procedures.</translate> |
|||
<translate><!--T:40--> Some extensions will contain a text-file named <tvar name="1"><code>README</code></tvar> (sometimes <tvar name="2"><code>INSTALL</code></tvar>) that will have more detailed information about that extension.</translate> |
|||
<translate><!--T:6--> See also:</translate> |
|||
''{{ll|Manual:Extensions#Installing an extension|2=<translate><!--T:32--> Manual:Extensions#Installing an extension</translate>}}'' |
|||
| ⚫ | |||
==How do I write my own extension?== <!--T:7--> |
==How do I write my own extension?== <!--T:7--> |
||
| Line 60: | Line 46: | ||
<translate><!--T:11--> In case your extension output is only dependent on some option or user context and not time, you can still let it get cached by the parser cache but make sure it's marked as one output variant (of many possible).</translate> |
<translate><!--T:11--> In case your extension output is only dependent on some option or user context and not time, you can still let it get cached by the parser cache but make sure it's marked as one output variant (of many possible).</translate> |
||
Use the {{ll|Manual:Hooks/PageRenderingHash|PageRenderingHash}} hook to influence the cache hash accordingly. |
<translate><!--T:49--> Use the <tvar name="1">{{ll|Manual:Hooks/PageRenderingHash|PageRenderingHash}}</tvar> hook to influence the cache hash accordingly.</translate> |
||
{{note|1=<translate><!--T:41--> In older versions of MediaWiki, you would use <tvar name="1">{{phpi|$parser->disableCache()}}</tvar> to disable caching, but this was deprecated in MW 1.28 and removed altogether in MW 1.35.</translate> |
{{note|1=<translate><!--T:41--> In older versions of MediaWiki, you would use <tvar name="1">{{phpi|$parser->disableCache()}}</tvar> to disable caching, but this was deprecated in MW 1.28 and removed altogether in MW 1.35.</translate>}} |
||
<translate> |
<translate> |
||
| Line 99: | Line 85: | ||
==How can I pass XML-style parameters in my extension tag?== <!--T:19--> |
==How can I pass XML-style parameters in my extension tag?== <!--T:19--> |
||
</translate> |
</translate> |
||
''<translate>See {{<tvar name=1>ll|Manual:Tag extensions#How can I pass XML-style parameters in my extension tag?</tvar>|Manual:Tag extensions#How can I pass XML-style parameters in my extension tag?}}</translate>'' |
''<translate><!--T:46--> See {{<tvar name=1>ll|Manual:Tag extensions#How can I pass XML-style parameters in my extension tag?</tvar>|Manual:Tag extensions#How can I pass XML-style parameters in my extension tag?}}</translate>'' |
||
<translate> |
<translate> |
||
==Extensions and Templates== <!--T:20--> |
==Extensions and Templates== <!--T:20--> |
||
</translate> |
</translate> |
||
''<translate>See {{<tvar name=1>ll|Manual:Tag extensions#Extensions and Templates</tvar>|Manual:Tag extensions#Extensions and Templates}}</translate>'' |
''<translate><!--T:47--> See {{<tvar name=1>ll|Manual:Tag extensions#Extensions and Templates</tvar>|Manual:Tag extensions#Extensions and Templates}}</translate>'' |
||
<translate> |
<translate> |
||
| Line 111: | Line 97: | ||
<translate><!--T:43--> Your extension (or another one installed) might be using <tvar name=1>{{phpi|parse()}}</tvar> function instead of <tvar name=2>{{phpi|recursiveTagParse()}}</tvar>.</translate> |
<translate><!--T:43--> Your extension (or another one installed) might be using <tvar name=1>{{phpi|parse()}}</tvar> function instead of <tvar name=2>{{phpi|recursiveTagParse()}}</tvar>.</translate> |
||
Then change it to <code>recursiveTagParse</code> |
<translate><!--T:50--> Then change it to <tvar name=1><code>recursiveTagParse</code></tvar>.</translate> |
||
<translate> |
<translate> |
||
==How can I determine in my extension, if an article is protected or not?== <!--T:24--> |
==How can I determine in my extension, if an article is protected or not?== <!--T:24--> |
||
</translate> |
</translate> |
||
| Line 139: | Line 126: | ||
==How do I get my extension to show up on Special:Version?== <!--T:31--> |
==How do I get my extension to show up on Special:Version?== <!--T:31--> |
||
</translate> |
</translate> |
||
''<translate>See {{<tvar name="1">ll|Manual:Developing extensions#Registering features with MediaWiki</tvar>|Manual:Developing extensions#Registering features with MediaWiki}}</translate>'' |
''<translate><!--T:48--> See {{<tvar name="1">ll|Manual:Developing extensions#Registering features with MediaWiki</tvar>|Manual:Developing extensions#Registering features with MediaWiki}}</translate>'' |
||
| ⚫ | |||
[[Category:Extensions{{#translation:}}| ]] |
[[Category:Extensions{{#translation:}}| ]] |
||
Latest revision as of 08:39, 3 January 2026

Where can I find a list of installed extensions?
The Special:Version page on each wiki contains a list of extensions that have registered themselves with the MediaWiki software. All extensions can be installed without showing up on Special:Version, if the developer does not include the correct code to list it there.
How do I enable an extension?
See Manual:Extensions/Installation and upgrade
How do I write my own extension?
See Manual:Developing extensions.
How do I disable caching for pages using my extension?
If you're writing e.g. special page:
global $wgOut;
$wgOut->enableClientCache(false);
For parser tag hooks:
function wfSomeHookFunction( $parser, $foo, $bar ) {
$parser->getOutput()->updateCacheExpiry(0);
...
}
In case your extension output is only dependent on some option or user context and not time, you can still let it get cached by the parser cache but make sure it's marked as one output variant (of many possible). Use the PageRenderingHash hook to influence the cache hash accordingly.
$parser->disableCache() to disable caching, but this was deprecated in MW 1.28 and removed altogether in MW 1.35.How do I render wikitext in my extension?
Special pages
When rendering output that will not be subject to parser cache, such as on a special page
global $wgOut;
$wgOut->parse( $text );
where $text is the wikitext to be parsed.
Parser hooks
See Manual:Tag extensions#How do I render wikitext in my extension?
How do I enable searching in my extension's output (dynamic content)?
You can't. Dynamic content can not be included in a static index.
How can I avoid modification of my extension's HTML output?
See Manual:Tag extensions#How can I avoid modification of my extension's HTML output?
How can I pass XML-style parameters in my extension tag?
See Manual:Tag extensions#How can I pass XML-style parameters in my extension tag?
Extensions and Templates
See Manual:Tag extensions#Extensions and Templates
"NaodW..." or "UNIQ..."
Your extension (or another one installed) might be using parse() function instead of recursiveTagParse().
Then change it to recursiveTagParse.
How can I determine in my extension, if an article is protected or not?
Use the Title class and the isProtected( ) method, e.g.
function extensionFunction() {
# Assume $title is the title object
if( $title->isProtected( 'edit' ) ) {
# Protected from editing, do things
} else {
# Not protected from editing
}
}
What permissions do I apply to the extensions folder?
All the scripts in the /wiki structure need to be readable and executable by the user that PHP runs as. All perms are usually 755 and owner/group being a different user. The LocalSettings.php file is created by the script on setup and so will be an example to set the rest by.
How do I get my extension to show up on Special:Version?
See Manual:Developing extensions#Registering features with MediaWiki