Template:Namespace: Difference between revisions
(new metatemplate) |
(replaced "empty" with more flexible "others", doc to reflect the change) |
||
Line 1: | Line 1: | ||
<includeonly>{{#switch: {{NAMESPACENUMBER:{{{page|{{FULLPAGENAME}}}}}}} | <includeonly>{{#switch: {{NAMESPACENUMBER:{{{page|{{FULLPAGENAME}}}}}}} | ||
| 0 = {{{main|{{ | | 0 = {{{main|{{{others|article}}}}}} | ||
| 1 = {{{talk|{{ | | 1 = {{{talk|{{{others|talk page}}}}}} | ||
| 2 = {{{user|{{ | | 2 = {{{user|{{{others|user page}}}}}} | ||
| 3 = {{{user talk|{{ | | 3 = {{{user talk|{{{others|user talk page}}}}}} | ||
| 4 = {{{118wiki|{ | | 4 = {{{118wiki|{{{others|project page}}}}}} | ||
| 5 = {{{118wiki talk| | | 5 = {{{118wiki talk|{{{others|project talk page}}}}}} | ||
| 6 = {{{file| | | 6 = {{{file|{{{others|file}}}}}} | ||
| 7 = {{{file talk|{{ | | 7 = {{{file talk|{{{others|file talk page}}}}}} | ||
| 8 = {{{mediawiki|{{ | | 8 = {{{mediawiki|{{{others|MediaWiki system page}}}}}} | ||
| 9 = {{{mediawiki talk|{ | | 9 = {{{mediawiki talk|{{{others|MediaWiki system talk page}}}}}} | ||
| 10 = {{{template|{{ | | 10 = {{{template|{{{others|template}}}}}} | ||
| 11 = {{{template talk|{{ | | 11 = {{{template talk|{{{others|template talk page}}}}}} | ||
| 12 = {{{help|{{ | | 12 = {{{help|{{{others|help page}}}}}} | ||
| 13 = {{{help talk|{ | | 13 = {{{help talk|{{{others|help talk page}}}}}} | ||
| 14 = {{{category| | | 14 = {{{category|{{{others|category}}}}}} | ||
| 15 = {{{category talk| | | 15 = {{{category talk|{{{others|category talk page}}}}}} | ||
| 1280 = {{{sim|{{ | | 1280 = {{{sim|{{{others|sim}}}}}} | ||
| 1281 = {{{sim talk|{{ | | 1281 = {{{sim talk|{{{others|sim talk page}}}}}} | ||
| page | | page | ||
}}</includeonly><noinclude> | }}</includeonly><noinclude> | ||
Line 30: | Line 30: | ||
Full usage: | Full usage: | ||
<pre>{{Namespace|page= | | <pre>{{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= }}</pre> | ||
At basic use, the template will print a reader-friendly name for the namespace of the page the template is placed in. | At basic use, the template will print a reader-friendly name for the namespace of the page the template is placed in. | ||
Line 80: | Line 80: | ||
'''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! | '''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 == | == Examples == | ||
Line 110: | Line 110: | ||
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: | 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: | ||
{{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.|page=Talk:Example}}}} | {{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.|page=Talk:Example}}}} | ||
If this is not something you want, empty all other values with parameter " | If this is not something you want, empty all other values with parameter "others": | ||
<pre>{{Ambox | <pre>{{Ambox | ||
| type=notice | | type=notice | ||
| text='''{{namespace | | text='''{{namespace | ||
| | |others= | ||
|main=You can edit articles like this one by clicking "edit" or "edit source" on top of the page. | |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". | |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". | ||
Line 120: | Line 120: | ||
}}</pre> | }}</pre> | ||
Now, you get: | Now, you get: | ||
{{Ambox | type=notice | text={{namespace| | {{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.}}}} | ||
And on a talk page: | And on a talk page: | ||
{{Ambox | type=notice | text={{namespace| | {{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.|page=Talk:Example}}}} | ||
The custom value can also be formatted, another template, category or something else. | The custom value can also be formatted, another template, category or something else. |
Latest revision as of 20:15, 2 March 2024
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:
This template has problems Fix them! |
If you put that template to an article (main namespace), the result would automatically be like this:
This article has problems Fix them! |
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.}} }}
Templates can only be edited with the source editor. |
On a file page:
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". |
In an article:
You can edit articles like this one by clicking "edit" or "edit source" on top of the page. |
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:
talk page |
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:
Templates can only be edited with the source editor. |
And on a talk page: