Help:Namespaces: Difference between revisions

no edit summary
m (1 revision)
No edit summary
 
Line 3:
Pages on a MediaWiki wiki are grouped into collections called "'''namespaces'''", which differentiate between the purpose of the pages at a high level. Pages in certain namespaces can also have special properties or behave differently when they interact with other pages.
 
Namespaces are indicated in page titles by prefixing the page name with "<ttcode>namespace:</ttcode>", so the prefix "<ttcode>{{NAMESPACE}}:</ttcode>" in this page's title ("{{FULLPAGENAME}}") indicates that this page is in the {{NAMESPACE}} namespace. Each namespace is identified by a number and a name, which can be translated and can also have some aliases.
 
A page whose name is ''not'' prefixed by a namespace lies in the [[#(Main)|mainspace]]. Note, however, that colons and prefixes can also appear in page titles ''without'' indicating a namespace: the page [[Foo:{{PAGENAME}}]] is a page located in the mainspace because the namespace "Foo" does not exist. Similarly the page [[{{NAMESPACE}}:Foo:{{PAGENAME}}]] is in the "{{NAMESPACE}}" namespace.
Line 29:
===={{ns:2}}====
 
Each user has a corresponding page in the {{ns:2}} namespace, which is linked to from edit histories, watchlists, recent changes, etc; wherever an individual user is uniquely identified. This page, and subpages of it, can be used by users to record information about themselves or to test and draft new content. Pages of the form "<ttcode style="whitespace:nowrap">{{ns:2}}:''UserName''/Foo'''.js'''</ttcode>" or "<ttcode style="whitespace:nowrap">{{ns:2}}:''UserName''/Foo'''.css'''</ttcode>" can only be edited by the user themselves or by [[Help:Sysops and permissions|administrators]].
 
===={{ns:3}}====
Line 48:
===={{ns:6}}====
[[Image:Wiki.png|right]]
The {{ns:6}} namespace is used to store metadata for images, videos, sound files and other media accessed via the {{ns:-2}} namespace. Each file has a corresponding page in the {{ns:6}} namespace, which is often used to hold licensing data. Linking ''directly'' to a page in this namespace instead includes the media file inline in the page: <ttcode style="white-space:nowrap"><nowiki>[[</nowiki>{{ns:6}}<nowiki>:Wiki.png|right]]</nowiki></ttcode> produces the image to the right. See [[Help:Images]] for more details of this link syntax. To create an [[Help:Links|internal link]] to the file page, you need to add a colon to the front of the namespace: <ttcode style="white-space:nowrap"><nowiki>[[:</nowiki>{{ns:6}}<nowiki>:Wiki.png|right]]</nowiki></ttcode> produces [[:{{ns:6}}:Wiki.png]].
The standard MediaWiki installation has alias "Image" for {{ns:6}} namespace - See [[Help:Namespaces#Namespace aliases|Namespace aliases]]. For linking media files directly, bypassing the description page, see [[#Media|Media namespace]].
 
Line 65:
===={{ns:10}}====
 
The {{ns:10}} namespace is used to hold [[Help:Templates|templates]], blocks of text or wikicode that are intended to be transcluded into several other pages. To facilitate this it has the special property that it is the ''default'' namespace for transclusions: the wikicode <ttcode style="white-space:nowrap"><nowiki>{{Foo}}</nowiki></ttcode> is equivalent to <ttcode style="white-space:nowrap"><nowiki>{{</nowiki>'''{{ns:10}}:'''<nowiki>Foo}}</nowiki></ttcode>.
 
===={{ns:11}}====
Line 81:
===={{ns:14}}====
 
The {{ns:14}} namespace contains [[Help:Categories|categories]], dynamic lists of other pages. To facilitate this, linking ''directly'' to a category page does not output an inline link, but instead includes the page into the associated category page. So the code <ttcode style="white-space:nowrap"><nowiki>[[</nowiki>{{ns:14}}<nowiki>:Help]]</nowiki></ttcode> causes a category link to appear at the bottom of the page (at the bottom in the box marked "{{MediaWiki:Pagecategories}}"). Clicking on that link takes you to the category page, where this page is visible in the category list. To create an inline link to a category page, you need to add a colon to the front of the namespace: <ttcode style="white-space:nowrap"><nowiki>[[:</nowiki>{{ns:14}}<nowiki>:Help]]</nowiki></ttcode> produces [[:{{ns:14}}:Help]]. See [[Help:Categories]] for more details on category link syntax.
 
===={{ns:15}}====
Line 136:
 
===Namespace aliases===
On some wikis there are also namespace ''aliases'': alternative names that will also be resolved to the localised names. For instance, a wiki might define "T" as an alias for {{ns:10}}, such that typing [[T:Foo]] is equivalent to [[{{ns:10}}:Foo]], saving a few characters and seconds. An actual example would be on the [[wikipedia:|English Wikipedia]], where "WP" is an alias for {{ns:4}}, which is the namespace "Wikipedia". By default, "Image" is an alias for {{ns:6}}, so <ttcode style="white-space:nowrap;"><nowiki>[[Image:Wiki.png]]</nowiki></ttcode> is equivalent to <ttcode style="white-space:nowrap;"><nowiki>[[</nowiki>{{ns:6}}<nowiki>:Wiki.png]]</nowiki></ttcode>.
 
===Custom namespaces===
Line 150:
;Magic words
 
The [[Help:Magic word|magic word]] <ttcode><nowiki>{{NAMESPACE}}</nowiki></ttcode> returns the value of the namespace the page is in.
 
;JavaScript
 
The JavaScript variable <ttcode>wgCanonicalNamespace</ttcode> contains the full namespace name. The variable <ttcode>wgNamespaceNumber</ttcode> contains the numerical index of the namespace.
 
;CSS
 
The <ttcode><nowiki><body></nowiki></ttcode> tag of the HTML page output is given two CSS classes that vary by namespace: A class <ttcode>ns-#</ttcode>, where # is the index of the namespace, and <ttcode>ns-XXX</ttcode>, where XXX is "<ttcode>subject</ttcode>" for all {{mediawiki|Manual:Namespace#Subject and talk namespaces|subject namespaces}}, "<ttcode>special</ttcode>" for pages in the {{ns:-1}} namespace, and "<ttcode>talk</ttcode>" for {{mediawiki|Manual:Namespace#Subject and talk namespaces|talk namespaces}}. So CSS code such as the following can be used to change the appearance of an object based on its namespace:
<source lang=css>
.ns-subject a