Manual:$wgNamespaceContentModels

From MediaWiki.org
Jump to navigation Jump to search
Translate this page; This page contains changes which are not marked for translation.

Other languages:
Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎日本語 • ‎polski • ‎português • ‎português do Brasil
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.

Icon apps query.svg About
Icon tools.svg Usage
Examples:
Icon-gears.svg Configuration settings

Support and development

Git-logo.svg Latest technical documentation (Git)
Wikimedia Phabricator logo.svg Phabricator
Namespaces: $wgNamespaceContentModels
Content types defined for a given namespace
Introduced in version: 1.21.0
Removed in version: still in use
Allowed values:
Default value: array()
Other settings: Alphabetical | By function

Details[edit]

Associative array mapping namespace IDs to the name of the content model pages in that namespace should have by default (use the CONTENT_MODEL_XXX constants). If no special content type is defined for a given namespace, pages in that namespace will use the CONTENT_MODEL_WIKITEXT (except for the special case of JavaScript and CSS pages).

Example[edit]

JSON[edit]

Suppose you have created a new custom namespace NS_JSON and you want all new pages in this namespace to have JSON content and to be supported by the appropriate content handler. Add the following to your LocalSettings.php file.

$wgNamespaceContentModels[NS_JSON] = CONTENT_MODEL_JSON;

P.S. If you already created pages in this namespace, see the talk page.