Template:Categorize: Difference between revisions

From HorizonXI Wiki
(Undo revision 59085 by Aramachus (talk))
Tag: Undo
m (added option to disable documentation and categorization simultaneously)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#switch:{{lc:{{{1|}}}}}|no categories|no cat|nc = |#default = {{#switch:{{NAMESPACE}}||Category={{{2|}}}|#default=}}}}</includeonly>
<includeonly><onlyinclude>{{#switch:{{lc:{{{1|}}}}}|no categories|no cat|ndnc|ncnd|nc = |#default = {{#switch:{{NAMESPACE}}||Category={{{2|}}}}}<!--
-->}}</onlyinclude></includeonly>
==Usage==
*First unnamed parameter: set to ''nc'', ''no cat'' or ''no categories'' to force the template to do nothing. ''ndnc'' or ''ncnd'' will also work, intended with [[Template:Preview Only Infobox]] to disable categorization and documentation at the same time.
*Second unnamed parameter: put whatever is supposed to happen if the first parameter is not set to one of the above.
*Note: The template will also do nothing if the page has a namespace other than the main namespace or the namespace "Category". E.g. in the namespace "Template" it will do nothing.
 
The actual usage of the template is intended for categorization, as the name suggests. It allows to control categorization in other templates by forwarding the first unnamed parameter.
 
Example:
 
If a template "NPC" contains the line <pre>{{categorize|{{{1|}}}|[[Category:NPC]]}}</pre>
Then a call like
<pre>
{{NPC|nc
...
}}
</pre>
will put the ''nc'' into the categorize template and cause it to do nothing.
 
A call like
<pre>
{{NPC
...
}}
</pre>
without specifying the first unnamed parameter in a way that Template:categorize processes it will make Template:categorize do whatever is in its second unnamed argument. In this example, this is apply <nowiki>[[Category:NPC]]</nowiki>.
 
Designing templates in this way allows to control categorization at template call, e.g. for use on example pages.

Latest revision as of 16:13, 5 August 2024

Usage

  • First unnamed parameter: set to nc, no cat or no categories to force the template to do nothing. ndnc or ncnd will also work, intended with Template:Preview Only Infobox to disable categorization and documentation at the same time.
  • Second unnamed parameter: put whatever is supposed to happen if the first parameter is not set to one of the above.
  • Note: The template will also do nothing if the page has a namespace other than the main namespace or the namespace "Category". E.g. in the namespace "Template" it will do nothing.

The actual usage of the template is intended for categorization, as the name suggests. It allows to control categorization in other templates by forwarding the first unnamed parameter.

Example:

If a template "NPC" contains the line

{{categorize|{{{1|}}}|[[Category:NPC]]}}

Then a call like

{{NPC|nc
...
}}

will put the nc into the categorize template and cause it to do nothing.

A call like

{{NPC
...
}}

without specifying the first unnamed parameter in a way that Template:categorize processes it will make Template:categorize do whatever is in its second unnamed argument. In this example, this is apply [[Category:NPC]].

Designing templates in this way allows to control categorization at template call, e.g. for use on example pages.