Extensions FAQ
[edit] How do I enable an extension?
Copy the extension PHP file to your extensions folder and add a require_once( "extensions/ExtensionName/ExtensionName.php" ); statement to your LocalSettings.php, with ExtensionName being the filename of your extension, such as MyExtension.php.
See also Manual:Extensions#Installing an extension
[edit] How do I write my own extension?
See Manual:Developing extensions.
[edit] 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->disableCache(); ... }
- Disable caching site-wide. This will sharply increase the amount of work that your server will have to perform. To disable all caching, put the following code in LocalSettings.php:
# Client-side caching: /** Allow client-side caching of pages */ $wgCachePages = false; /** * Set this to current time to invalidate all prior cached pages. Affects both * client- and server-side caching. * You can get the current date on your server by using the command: * date +%Y%m%d%H%M%S */ $wgCacheEpoch = 'date +%Y%m%d%H%M%S';
I would recommend using the php function date rather than a system call (system calls might be forbidden, date might be broken or some strange person could have the idea of running php on a windows server...
$wgCacheEpoch = date('YmdHis');
[edit] How do I render wikitext in my extension?
[edit] 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.
[edit] Parser hooks
See Manual:Tag extensions#How do I render wikitext in my extension?
[edit] 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.
[edit] 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?
[edit] 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?
[edit] Extensions and Templates
See Manual:Tag extensions#Extensions and Templates
[edit] "NaodW..." or "UNIQ..."
In previous version of MediaWiki, another problem with templates and extensions was 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).
[edit] 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 } }
[edit] 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.
[edit] How do I get my extension to show up on Special:Version?
See Manual:Developing extensions#Registering features with MediaWiki
| Language: | English • 日本語 • Polski |
|---|
| Extensions: | Category • All • Requests • Tag extensions • Extension Matrix • Extensions FAQ • Extension hook registry • Extension namespace registry |
|---|