| This is a Template documentation subpage for Template:NAMESPACEID. It contains usage information, categories, and other content that is not part of the original template page. |
Description
Template:NAMESPACEID/doc returns the namespace ID of page given, or of the current page.
Usage
- {{NAMESPACEID}} → 10
- {{NAMESPACEID|}} → 0 (Article namespace)
- {{NAMESPACEID|{{ns:0}}}} → 0 (Article namespace)
- {{NAMESPACEID|Talk}} → 1
Namespace aliases are accepted, too:
- {{NAMESPACEID|Image}} → 6
- {{NAMESPACEID|File}} → 6
- {{NAMESPACEID|MW}} → Invalid namespace in {{NAMESPACEID}}
- {{NAMESPACEID|Project}} → 4
- {{NAMESPACEID|Math Wiki}} → 4
Invalid input returns an error, which can be caught with the #iferror parser function:
- {{NAMESPACEID|Foo}} → Invalid namespace in {{NAMESPACEID}}
See also
- mw:Help:Magic words#Namespaces
- {{Is subpage namespace}}