Manual:$wgExtraNamespaces

From MediaWiki.org
Jump to: navigation, search
Namespaces: $wgExtraNamespaces
Additional namespaces.
Introduced in version: 1.3.3
Removed in version: still in use
Allowed values: array
Default value: array()

Other settings: Alphabetical | By Function


Details[edit | edit source]

$wgExtraNamespaces is used to configure additional, custom namespaces for a wiki. It can also be used to rename the default namespaces.

This is covered in detail on Manual:Using custom namespaces. Note that the first custom namespace should use the ID 100, as IDs from 0 to 99 are reserved (and negative IDs have a special meaning). The maximum namespace ID was 255 on some older (< MW 1.5) MediaWiki versions, but 16-bit namespace numbers (through to 32767) are supported in all current releases.

When you define a namespace or set a name of a namespace (including talk pages) to something which contains a space, use an underscore in place of the space. For example, 'My Namespace' or 'My Namespace Talk' is an invalid name and will cause problems. Instead, use 'My_Namespace' or 'My_Namespace_Talk' in the namespace definition.

Example[edit | edit source]

To add a namespace with the name 'Foo' to your wiki you need to create 2 new namespaces (even number for the Foo page and odd number for its associated talk page):

// define namespace constants
define("NS_FOO", 100); // This MUST be even.
define("NS_FOO_TALK", 101); // This MUST be the following odd integer.
 
// add namespaces
$wgExtraNamespaces[NS_FOO] = "Foo";
$wgExtraNamespaces[NS_FOO_TALK] = "Foo_talk";
In case extra namespaces were added like e.g.
$wgExtraNamespaces = array( 100 => "Foo", 101 => "Foo_talk" );
or
$wgExtraNamespaces[100] = "Foo";
$wgExtraNamespaces[101] = "Foo_talk";
without defining namespace constants, e.g. NS_FOO you should safely add them as described above. Make sure that the namesspace IDs and names continue to correspond.

See also[edit | edit source]

  • Namespace IDs used by extensions – Shows you a list of namespace IDs you should definitely avoid to prevent namespace conflicts, thus the first custom namespace may encounter conflicts even at ID 110 though 100 is theoretically possible. It is recommened to define custom namespaces with IDs starting at 3000 to avoid namespace conflicts.
  • Manual:$wgExtraGenderNamespaces
Language: English  • Deutsch • 日本語 • polski