Manual:$wgContentHandlers
| Content Models and Handlers |
|---|
| MediaWiki allows for page content types other than wikitext. It offers built-in support for JavaScript, CSS, JSON and plain text. Extensions can use MediaWiki's ContentHandler mechanism to add new content models for accepting different formats and controlling how they are rendered, stored and edited. |
| About |
|
About the ContentHandler Content handlers and their implementation |
| Usage |
|
Changing the content model of a page Changing the content model of a namespace Extensions using the ContentHandler Adding content models with an extension Examples: |
| Configuration settings |
|
$wgContentHandlers $wgNamespaceContentModels $wgContentHandlerTextFallback $wgContentHandlerUseDB |
| Support and development |
|
Latest technical documentation (Git) Phabricator |
| v · d · e |
| Content handlers and storage: $wgContentHandlers | |
|---|---|
| Mapping of content type handlers |
|
| Introduced in version: | 1.21.0 |
| Removed in version: | Still in use |
| Allowed values: | (array of PHP class names) |
| Default value: | (see below) |
| Other settings: Alphabetical | By function | |
Details
[edit ]Plugins for page content model handling. Each entry in the array maps a model ID constant to a PHP class name.
When undeploying an extension that provides handling for a content model, that content model becomes unsupported, leading to MWUnknownContentModelExceptions to be raised. To avoid this, the content model in question can be defined to use the UnknownContentHandler:
$wgContentHandlers['foo-bar'] = 'UnknownContentHandler';
Starting with MediaWiki 1.43, you need to use FallbackContentHandler instead of UnknownContentHandler:
$wgContentHandlers['foo-bar'] = 'FallbackContentHandler';
This allows pages that use the new unsupported content model to still be accessible, even though their content can no longer be shown.
Alternatively, if the content model in question is a text based model, it can be re-defined to be handled as plain text:
$wgContentHandlers['foo-bar'] = 'TextContentHandler';
The content of pages that use this content model remain readable and editable, but lose any special capabilities and markup support.
Default value
[edit ]$wgContentHandlers = [ // the usual case CONTENT_MODEL_WIKITEXT => [ 'class' => WikitextContentHandler::class, 'services' => [ 'TitleFactory', 'ParserFactory', 'GlobalIdGenerator', 'LanguageNameUtils', 'LinkRenderer', 'MagicWordFactory', 'ParsoidParserFactory', ], ], // dumb version, no syntax highlighting CONTENT_MODEL_JAVASCRIPT => JavaScriptContentHandler::class, // simple implementation, for use by extensions, etc. CONTENT_MODEL_JSON => JsonContentHandler::class, // dumb version, no syntax highlighting CONTENT_MODEL_CSS => CssContentHandler::class, // plain text, for use by extensions, etc. CONTENT_MODEL_TEXT => TextContentHandler::class, // fallback for unknown models, from imports or extensions that were removed CONTENT_MODEL_UNKNOWN => FallbackContentHandler::class, ];
$wgContentHandlers = [ // the usual case CONTENT_MODEL_WIKITEXT => [ 'class' => WikitextContentHandler::class, 'services' => [ 'TitleFactory', 'ParserFactory', 'GlobalIdGenerator', 'LanguageNameUtils', 'MagicWordFactory', ], ], // dumb version, no syntax highlighting CONTENT_MODEL_JAVASCRIPT => JavaScriptContentHandler::class, // simple implementation, for use by extensions, etc. CONTENT_MODEL_JSON => JsonContentHandler::class, // dumb version, no syntax highlighting CONTENT_MODEL_CSS => CssContentHandler::class, // plain text, for use by extensions, etc. CONTENT_MODEL_TEXT => TextContentHandler::class, // fallback for unknown models, from imports or extensions that were removed CONTENT_MODEL_UNKNOWN => FallbackContentHandler::class, ];
$wgContentHandlers = [ // the usual case CONTENT_MODEL_WIKITEXT => WikitextContentHandler::class, // dumb version, no syntax highlighting CONTENT_MODEL_JAVASCRIPT => JavaScriptContentHandler::class, // simple implementation, for use by extensions, etc. CONTENT_MODEL_JSON => JsonContentHandler::class, // dumb version, no syntax highlighting CONTENT_MODEL_CSS => CssContentHandler::class, // plain text, for use by extensions, etc. CONTENT_MODEL_TEXT => TextContentHandler::class, // fallback for unknown models, from imports or extensions that were removed CONTENT_MODEL_UNKNOWN => FallbackContentHandler::class, ];
$wgContentHandlers = [ // the usual case CONTENT_MODEL_WIKITEXT => WikitextContentHandler::class, // dumb version, no syntax highlighting CONTENT_MODEL_JAVASCRIPT => JavaScriptContentHandler::class, // simple implementation, for use by extensions, etc. CONTENT_MODEL_JSON => JsonContentHandler::class, // dumb version, no syntax highlighting CONTENT_MODEL_CSS => CssContentHandler::class, // plain text, for use by extensions, etc. CONTENT_MODEL_TEXT => TextContentHandler::class, ];
$wgContentHandlers = [ // the usual case CONTENT_MODEL_WIKITEXT => 'WikitextContentHandler', // dumb version, no syntax highlighting CONTENT_MODEL_JAVASCRIPT => 'JavaScriptContentHandler', // simple implementation, for use by extensions, etc. CONTENT_MODEL_JSON => 'JsonContentHandler', // dumb version, no syntax highlighting CONTENT_MODEL_CSS => 'CssContentHandler', // plain text, for use by extensions, etc. CONTENT_MODEL_TEXT => 'TextContentHandler', ];
$wgContentHandlers = array( // the usual case CONTENT_MODEL_WIKITEXT => 'WikitextContentHandler', // dumb version, no syntax highlighting CONTENT_MODEL_JAVASCRIPT => 'JavaScriptContentHandler', // dumb version, no syntax highlighting CONTENT_MODEL_CSS => 'CssContentHandler', // plain text, for use by extensions etc CONTENT_MODEL_TEXT => 'TextContentHandler', );