Template:NAMESPACEID
10
Returns the namespace ID of page given, or of the current page.
Wikibooks namespaces | |||
---|---|---|---|
Basic namespaces | Talk namespaces | ||
0 | Main | Talk | 1 |
2 | User | User talk | 3 |
4 | Wikibooks | Wikibooks talk | 5 |
6 | File | File talk | 7 |
8 | MediaWiki | MediaWiki talk | 9 |
10 | Template | Template talk | 11 |
12 | Help | Help talk | 13 |
14 | Category | Category talk | 15 |
102 | Cookbook | Cookbook talk | 103 |
108 | Transwiki | Transwiki talk | 109 |
110 | Wikijunior | Wikijunior talk | 111 |
112 | Subject | Subject talk | 113 |
710 | TimedText | TimedText talk | 711 |
828 | Module | Module talk | 829 |
Virtual namespaces | |||
-1 | Special | ||
-2 | Media |
Usage
{{NAMESPACEID}}
→ 10{{NAMESPACEID|}}
→ 0 (Main namespace){{NAMESPACEID|{{ns:0}}}}
→ 0 (Main namespace){{NAMESPACEID|Talk}}
→ 1
Namespace aliases are accepted, too:
{{NAMESPACEID|Image}}
→ 6{{NAMESPACEID|File}}
→ 6{{NAMESPACEID|WB}}
→ 4{{NAMESPACEID|Project}}
→ 4{{NAMESPACEID|Wikibooks}}
→ 4
Invalid input returns an error, which can be caught with the #iferror parser function:
{{NAMESPACEID|Foo}}
→ Invalid namespace in {{NAMESPACEID}}