math

10

Template documentation (for the above template, sometimes hidden or invisible)[view] [edit] [history] [refresh]

Description

Template:NAMESPACEID 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


The above Template documentation is transcluded from Template:NAMESPACEID/doc. (edit | history)
Editors can experiment in this template’s sandbox (create) and testcases (create) pages
Please add categories and interwikis to the /doc subpage.
Subpages of this template