Template:If ns: Difference between revisions

From NPOWiki
Jump to navigation Jump to search
(create)
 
(forgot talk)
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
     {{#expr:
     {{#expr:
       {{{1}}}
       {{{1}}}
     }}|
     }}
     {{NAMESPACE}}|
     |{{NAMESPACE}}
     {{NAMESPACENUMBER}}
     |{{NAMESPACENUMBER}}
   }}|
   }}
   {{ucfirst:
   |{{ucfirst:
     {{lc:
     {{#switch:
       {{#ifeq:
       {{lc:
        {{lc:
          {{{1}}}
        }}|
        main|
        |
         {{{1}}}
         {{{1}}}
       }}
       }}
      |main=
      |project={{SITENAME}}
      |project talk={{SITENAME}} talk
      |#default={{{1}}}
     }}
     }}
   }}|
   }}
   {{#if:
   |{{#if:
     {{{2|}}}|
     {{{2|}}}
     {{{2}}}
     |{{{2}}}
   }}|
   }}
   {{#if:
   |{{#if:
     {{{3|}}}|
     {{{3|}}}
     {{{3}}}
     |{{{3}}}
   }}
   }}
}}</includeonly><noinclude>{{documentation}}</noinclude>
}}</includeonly><noinclude>{{documentation}}</noinclude>

Latest revision as of 04:02, 21 August 2020

Documentation [edit]

This template is used to give different behavior in different namespaces. For example, you may not want to apply categories when a particular template is used outside of the mainspace.

Parameters

  • first unnamed parameter: the namespace to check the current namespace against.
    • You can use the namespace name (first letter is case insensitive), or the number if required (name is preferred for readability).
    • To check against the main namespace, use "main" or 0.
    • Remember that namespaces start at main = 0 and talk namespaces are odd.
    • As with links, "Project" is an alias for the site namespace (NPOWiki:)
  • second unnamed parameter: what to do if the current namespace equals the tested namespace.
  • third unnamed parameter: what to do if the namespaces are different.

Examples

  • {{if ns|template|this is a template page|not a template page}} produces: this is a template page
  • {{if ns|0|mainspace page|not mainspace}} produces: not mainspace

The above documentation is transcluded from Template:If ns/doc.