Help:Namespace

From LinuxMCE
Revision as of 15:26, 30 September 2012 by Mcefan (Talk | contribs) (Built-in namespaces)

Jump to: navigation, search
Home | Editing help | Table of contents (2)



Introduction to namespaces

Namespaces: the containers

Articles in the Wiki are placed in locations called "namespaces". Namespaces are the Wiki architecture components that hold all articles. The final location of an article is the one that has been specified through its title prefix following the construct Namespace:Title.
If an article is titled without the use of the optional location prefix (:Title), it is placed in the main namespace, which is the default location. This is so because the main namespace is the null character.

Why namespaces?

Namespaces are administrative boundaries used to separate content from policy and discussion.
They isolate pages based on their intended use:

  • public viewing
  • private information intended for the editing community.



When is a new namespace needed?

Mainly when a content type is to be reserved for a defined group of users. If you are a user, all you need to know is that all articles are in the "Main" namespace by default. You do not need a new namespace. Continue reading from #Where to place the article? below.



Working with namespaces

How to view the contents of a namespace

The special page "Special:Allpages" contains all the articles created in the wiki by its editors. It lists the contents of the "Main" namespace.
The "Namespace:" drop down menu on that page enables you to select a different namespace and click the "Go" button to view the articles it contains.

These work:  [[Special:Allpages]]  [[Special:Specialpages]]    [[:help]] 
These don't: [[Special:Help]][[Help:]]
[Help:] [[Special:Help:]] [[innamespace:Help]]



Where to place the article?

Before starting a new article, a decision has to be made about its intended use and audience. Each new article should be placed in the namespace that has related articles that are used for the same purpose.

Placing an article in a namespace

The final location of an article is determined through its title. The title of an article is a special structure that provides a facility to specify the destination of the article.
The construct is: Location:Title.
The location prefix specifies where the article should be located in reference to all other articles on the wiki.

Moving articles between namespaces

To move an article, all that is needed is a change of prefix (location).

How to specify the namespace(s) to search

The namespaces searched are the ones specified in the "search" section of the Preferences.

Namespace variables

The namespace is returned by {{NAMESPACE}} . On this page, it returns "Help".

{{FULLPAGENAME}} returns both the namespace and pagename as follows: "Help:Namespace"

The following does not work for this implementation but is included here for reference purposes.
List and numbers of the namespaces: http://wiki.linuxmce.org/api.php?action=query&meta=siteinfo&siprop=namespaces

Click here to view a detailed list of the namespaces in this wiki.




Namespace administration

Namespace administration

How to create a new namespace

This is an administrative function used to add custom namespaces to the wiki to further separate content and allow more logical organization. Use namespaces to separate articles just as you would use folders to keep documents.

A custom namespace can be used to hold content that should not be shown on the search results page, for example pages that are used only for transclusion.

The remainder of this section are administrative notes.

Edit the configuration file

  1. Open the /var/www/html/mediawiki/LocalSettings.php file
  2. Add a line to create the new namespace:
All namespaces require a numerical index
Custom namespaces are indexed starting with 100
  • Even indexes are content namespaces:
  • Odd indexes are discussion ('talk:') namespaces
$wgExtraNamespaces[100] = "Foo";
$wgExtraNamespaces[101] = "Foo_talk";

Create and protect the namespace

# create namespace
define("NS_FOO",100);
define("NS_FOO_TALK",101);
$wgExtraNamespaces[NS_FOO] = "Foo";
$wgExtraNamespaces[NS_FOO_TALK] = "Foo_talk";
# protect namespace $wgNamespaceProtection[NS_FOO] = Array("editfoo"); #permission "editfoo" required to
edit the foo namespace $wgNamespacesWithSubpages[NS_FOO] = true; #subpages enabled for the foo namespace $wgGroupPermissions['*']['editfoo'] = false; #permission "editfoo" denied to all $wgGroupPermissions['sysop']['editfoo'] = true; #permission "editfoo" granted to
users in the "sysop" group


Specify that it is a content namespace

If the namespace is created for additional content (articles), indicate it in the configuration:

$wgContentNamespaces[] = 100;

Give it an alias if necessary

It is possible to define alias names for any namespace using the $wgNamespaceAliases configuration directive.

But take note:

   * Namespace prefixes should not be confused with prefixes for interwiki linking.
   * If a page title contains a colon, but the initial part of the title is not one of the pre-defined namespaces, that page is considered to be in the main namespace.



Resolving namespace conflicts

When a page is created in a namespace that doesn't exist, e.g. "Bar:Some page", it is treated as being in the main namespace. This will conflict in the future with a new namespace of the same name. The articles will have to be moved.
Within the maintenance directory, there is a maintenance script which performs the above operation more effectively for a large number of pages; namespaceDupes.php. Alternatively, the following query can be used:

UPDATE page SET
page_title = REPLACE(page_title, 'Bar:', ),
page_namespace = 100
WHERE `page_title` LIKE 'Bar:%' AND page_namespace=0



Removing custom namespaces

The problem addressed above also occurs when a custom namespace definition is removed; the wiki is no longer aware of the numerical index for the namespace, and attempts to search the main namespace for the desired pages, leading to inaccessible content. This is a rare occurrence, since most sites will not need namespaces removed, but it is a problem.

Read more

Note
This article section has external references that will be added soon.