Template:Namespace

From 118Wiki
Jump to navigation Jump to search
Template Documentation
This is a metatemplate that can be used in other templates to identify the namespace of a page or to trigger a specific response depending on the namespace.

Not to be confused with wiki magic word {{NAMESPACE}}.

Usage

Basic usage:

{{Namespace}}

Full usage:

{{Namespace|page= |others= |main= |talk= |user= |user talk= |118wiki= |118wiki talk= |file= |file talk= |mediawiki= |mediawiki talk= |template= |template talk= |help= |help talk= |category= |category talk= |sim= |sim talk= }}

At basic use, the template will print a reader-friendly name for the namespace of the page the template is placed in.

{{Namespace}}

Result: template

If you want that the template produces something else in a specific namespace, use the parameter with appropriate name. Note that the parameters are in lower case.

Namespace Parameter Default print
(main) main= article
Talk talk= talk page
User user= user page
User talk user talk= user talk page
118Wiki 118wiki= project page
118Wiki talk 118wiki talk= project talk page
File file= file
File talk file talk= file talk page
MediaWiki mediawiki= MediaWiki system page
MediaWiki talk mediawiki talk= MediaWiki system talk page
Template template= template
Template talk template talk= template talk page
Help help= help page
Help talk help talk= help talk page
Category category= category
Category talk category talk= category talk page
SIM sim= sim
SIM talk sim talk= sim talk page

page parameter can be used to determine from which page the namespace is taken. If left empty, takes the namespace of the current page. Note that this parameter doesn't check if the page actually exists!

others parameter determines the content displayed on every namespace except those that have a custom text. If left empty, the nothing will appear on pages in namespace other than those defined.

Examples

Basic template text

Let's say you want to create a message box that informs the reader of a content problem on the page. You want the template to know what type of a page it is placed in.

{{Ambox 
| type=content 
| text='''This {{namespace}} has problems''' <br> <small>Fix them!</small>}}

Since this is a template page, you will get the following result:

If you put that template to an article (main namespace), the result would automatically be like this:

Template custom text

Let's say you want to create a message box that gives instructions how to edit a specific types of pages. For example's sake, let's say you want the template to explain articles, files and templates.

{{Ambox 
| type=notice 
| text='''{{namespace
  |main=You can edit articles like this one by clicking "edit" or "edit source" on top of the page.
  |file=You can upload a new version of this file by clicking "Upload a new version of this file". To edit the file information page, click "edit" or "edit source".
  |template=Templates can only be edited with the source editor.}}
}}

On a file page:

In an article:

Note that if you place this template to a page other than article, file or template, it will print the namespace name as usual. For example, on a talk page, this is what you would get:

If this is not something you want, empty all other values with parameter "others":

{{Ambox 
| type=notice 
| text='''{{namespace
  |others=
  |main=You can edit articles like this one by clicking "edit" or "edit source" on top of the page.
  |file=You can upload a new version of this file by clicking "Upload a new version of this file". To edit the file information page, click "edit" or "edit source".
  |template=Templates can only be edited with the source editor.}}
}}

Now, you get:

And on a talk page:

The custom value can also be formatted, another template, category or something else.