Extensions FAQ

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions

Where can I find a list of installed extensions?[edit | edit source]

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?[edit | edit source]

For most extensions, copy the extension PHP file (or directory) to your extensions/ folder and add the following statement to your LocalSettings.php, with ExtensionName being the filename of your extension, such as MyExtension.php.

require_once "extensions/ExtensionName/ExtensionName.php";

Some extensions, however, have additional steps and/or different installation procedures. Some extensions will contain a text-file named README (sometimes INSTALL) that will have more detailed information about that extension.

How do I write my own extension?[edit | edit source]

See Manual:Developing extensions.

How do I disable caching for pages using my extension?[edit | edit source]

If you're writing e.g. special page:

 global $wgOut;
 $wgOut->enableClientCache(false);

For parser tag hooks:

 function wfSomeHookFunction( $parser, $foo, $bar ) {
     $parser->disableCache();
     ...
 }

How do I render wikitext in my extension?[edit | edit source]

Special pages[edit | edit source]

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[edit | edit source]

See Manual:Tag extensions#How do I render wikitext in my extension?

How do I enable searching in my extension's output (dynamic content)?[edit | edit source]

You can't. Dynamic content can not be included in a static index.

How can I avoid modification of my extension's HTML output?[edit | edit source]

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?[edit | edit source]

See Manual:Tag extensions#How can I pass XML-style parameters in my extension tag?

Extensions and Templates[edit | edit source]

See Manual:Tag extensions#Extensions and Templates

"NaodW..." or "UNIQ..."[edit | edit source]

In previous versions of MediaWiki, there was a problem with templates and extensions that caused the appearance of "NaodW..." or "UNIQ..." strings in the template output. MediaWiki 1.5(.1) has problems with some PHP versions that causes that output. You should upgrade to MediaWiki 1.5.2 or later.

Another clue is that your extension (or another one installed) might be using parse() function instead of recursiveTagParse(). Then change it to recursiveTagParse (using the parser given in parameter or $wgParser).

How can I determine in my extension, if an article is protected or not?[edit | edit source]

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?[edit | edit source]

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?[edit | edit source]

See Manual:Developing extensions#Registering features with MediaWiki

Language: English  • 日本語 • polski • português do Brasil
Extensions: CategoryAllRequestsTag extensionsExtensions FAQExtension hook registryExtension namespace registry