Help:Custom namespaces

From Web
Revision as of 18:33, 18 November 2006 by Corni (talk | contribs) (1 revision(s))
Jump to navigation Jump to search

Template:H:h

For information on custom namespaces on the Meta-Wiki, see m:Meta:Namespaces.

If you want to add a custom namespace, you need to do the following:

  1. Pick the names of your namespaces and their associated talk pages. Do not include spaces in the name, but instead use an underscore character (it will be converted to a space character by the user interface). If you want to include special characters in the name, you can use the default character code of your system (which is ISO 8859 for windows, e.g. á for á). Do not save LocalSettings.php as Unicode, because PHP cannot handle it. Then pick the namespace numbers. Even numbers are for namespaces containing actual articles, odd numbers are reserved for talk pages. Numbering for custom namespaces start at 100.
  2. Goto /includes/DefaultSettings.php and copy the variables $wgExtraNamespaces, $wgNamespacesWithSubpages, and $wgNamespacesToBeSearchedDefault into LocalSettings.php
    Note: If $wgExtraNamespaces is not in DefaultSettings.php, you probably have a very old version of MediaWiki (1.3.2 or older). You should upgrade to the current release, as there have been bug and security fixes since then.
  3. To $wgExtraNamespaces, add the name of your namespace and its talk page, using the names and numbers chosen in step 1.
    • Example:
    $wgExtraNamespaces =
    array(100 => "Foo", 101 => "Foo_Talk");
    Note: Any existing pages whose titles start with the letters "Foo:" or "Foo talk:" will become unavailable, so you'd better rename them first.
  4. If you want sub pages, add them to $wgNamespacesWithSubpages
  • Example for MediaWiki 1.4.x and older:
$wgNamespacesWithSubpages = 
       array( -1 => 0, 0 => 0, 1 => 1, 2 => 1, 3 => 1,
              4 => 0, 5 => 1, 6 => 0, 7 => 1, 
              8 => 0, 9 => 1, 10 => 0,11 => 1,
              100 => 1, 101 => 1 );
  • Example for MediaWiki 1.5.x:
$wgNamespacesWithSubpages = array(
	NS_TALK           => true,
 	NS_USER           => true,
 	NS_USER_TALK      => true,
 	NS_PROJECT_TALK   => true,
 	NS_IMAGE_TALK     => true,
 	NS_MEDIAWIKI_TALK => true,
 	NS_TEMPLATE_TALK  => true,
 	NS_HELP_TALK      => true,
 	NS_CATEGORY_TALK  => true,
 	100               => true,
 	101               => true
);

or, using some PHP magic, you can also do:

$wgNamespacesWithSubpages += array(
 	100               => true,
 	101               => true
);
  1. The new namespaces can be searched by default, by enabling their variables in $wgNamespacesToBeSearchedDefault
  • Example for MediaWiki 1.4.x and older:
$wgNamespacesToBeSearchedDefault =
       array( -1 => 0, 0 => 1, 1 => 0, 2 => 0, 3 => 0,
               4 => 0, 5 => 0, 6 => 0, 7 => 0,
               8 => 0, 9 => 1, 10 => 0, 11 => 1,
               100 => 1, 101 => 1 );
  • Example for MediaWiki 1.5.x:
$wgNamespacesToBeSearchedDefault = array( 
       -1                => false, 
       NS_MAIN           => true, 
       NS_USER           => false,
       NS_USER_TALK      => false, 
       NS_PROJECT_TALK   => false, 
       NS_IMAGE_TALK     => false, 
       NS_IMAGE_TALK     => false, 
       NS_TEMPLATE_TALK  => false, 
       NS_HELP_TALK      => false, 
       NS_CATEGORY_TALK  => false, 
       100               => true, 
       101               => true 
);
  1. The changes will be effective the moment you save LocalSettings.php – you do not need to restart any servers.


Further information on Namespaces

Other pages for further Namespaces information: