Difference between revisions of "Template:Infobox Template/categories"

From Twinsuniverse
Jump to: navigation, search
(added the feature to specify maintenance tasks)
(eliminated the now obsolete parameter name)
Line 1: Line 1:
 
<includeonly>{{
 
<includeonly>{{
#if: {{{cat1|}}}
+
#if: {{{1|}}}
|{{#if: {{{cat2|}}} <!-- multiple arguments -->
+
|{{#if: {{{2|}}} <!-- multiple arguments -->
 
   | {{categorizer|category=Multi-categorizing templates|label=Multiple:|nocat={{{nocat|false}}}}}
 
   | {{categorizer|category=Multi-categorizing templates|label=Multiple:|nocat={{{nocat|false}}}}}
 
   | {{categorizer|category=Categorizing templates|label=One:|nocat={{{nocat|false}}}}}}}
 
   | {{categorizer|category=Categorizing templates|label=One:|nocat={{{nocat|false}}}}}}}
 
   </td></tr>
 
   </td></tr>
 
   <tr><td colspan="2">{{ <!-- one or more arguments -->
 
   <tr><td colspan="2">{{ <!-- one or more arguments -->
   #vardefine: cat | 1 }}{{
+
   #vardefine: arg | 1 }}{{
   #while: | {{#explode:{{{cat{{#var: cat }}|}}}|!|0}}
+
   #while: | {{#explode:{{{ {{#var: arg }}|}}}|!|0}}
 
   |<nowiki/>
 
   |<nowiki/>
* {{categorizer|category={{#explode:{{{cat{{#var: cat }}|}}}|!|0}}|catlabel={{#ifeq:{{#explode:{{{cat{{#var: cat }}|}}}|!|2}}|maintenance|maintenance|category}}|label={{#explode:{{{cat{{#var: cat }}|}}}|!|1}}|nocat=false}}{{
+
* {{categorizer|category={{#explode:{{{ {{#var: arg }}|}}}|!|0}}|catlabel={{#ifeq:{{#explode:{{{ {{#var: arg }}|}}}|!|2}}|maintenance|maintenance|category}}|label={{#explode:{{{ {{#var: arg }}|}}}|!|1}}|nocat=false}}{{
     #vardefine: cat | {{#expr: {{#var: cat }} + 1 }}}}
+
     #vardefine: arg | {{#expr: {{#var: arg }} + 1 }}}}
 
   }}
 
   }}
 
|<!-- no arguments -->
 
|<!-- no arguments -->
Line 18: Line 18:
  
 
==Parameters==
 
==Parameters==
* '''cat1''': The name of the category the template may categorize under, with the value that it requires to do so, separated by exclamation mark (parameter allows duplicates with number; cat1, cat2, cat3, etc)
+
# The name of the category that the template may categorize under, with the accompanying value, separated by exclamation mark (no parameter name, multiple parameters allowed, case sensitive)
 
* '''nocat''': Whether or not to suppress categorization under the automatically chosen category (defaults to false, which means auto categorization).
 
* '''nocat''': Whether or not to suppress categorization under the automatically chosen category (defaults to false, which means auto categorization).
  
  
'''''Note:''' the number-suffixed parameters must be specified in proper order, because the first empty/not specified one terminates the list.''
+
'''''Note:''' the unnamed parameters must be specified in proper order if using their positional numbers, because the first number that is empty/not specified terminates the list. If the list is empty this way, the default 'none' category will be used.''
  
'''''Note:''' although this template does not limit the amount of possible cat# parameters, the parent infobox limits to thirty.''
+
'''''Note:''' although this template does not limit the amount of possible unnamed parameters, the parent infobox limits to thirty.''
 
+
'''''Note:''' if no cat# parameters are detected before the list is terminated, the default 'none' category will be used. These parameters always require a number, even if there is only one.''
+
  
 
==Syntax==
 
==Syntax==
  <nowiki>{{Infobox Template/categories|cat1=value!value}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|value!value}}</nowiki>
  
 
<span style="color:red">Warning</span>: this template will often force a table cell to split in two, so do not use it outside table cells! Infoboxes use tables, so in there would be fine.
 
<span style="color:red">Warning</span>: this template will often force a table cell to split in two, so do not use it outside table cells! Infoboxes use tables, so in there would be fine.
  
 
==Examples==
 
==Examples==
Common use includes at least the '''cat1''' parameter to specify the category a template may categorize under, with both category name and value specified:
+
Common use includes at least one unnamed parameter to specify the category a template may categorize under, with the value that is required to select that category:
  <nowiki>{{Infobox Template/categories|cat1=Child characters!Child}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|Child characters!Child}}</nowiki>
  
 
:{{categorizer|category=Categorizing templates|label=One:|nocat=true}}
 
:{{categorizer|category=Categorizing templates|label=One:|nocat=true}}
Line 42: Line 40:
  
 
You can also specify multiple categories for one template:
 
You can also specify multiple categories for one template:
  <nowiki>{{Infobox Template/categories|cat1=Child characters!Child|cat2=Adult characters!Adult}}</nowiki>
+
  <nowiki>{{Infobox Template/categories
 +
|Child characters!Child
 +
|Adult characters!Adult
 +
}}</nowiki>
  
 
:{{categorizer|category=Multi-categorizing templates|label=Multiple:|nocat=true}}
 
:{{categorizer|category=Multi-categorizing templates|label=Multiple:|nocat=true}}
Line 49: Line 50:
  
  
Additionally, it is possible to specify that a category is a maintenance task instead, by providing "maintenance" as the third value for any cat# parameter:
+
Additionally, it is possible to specify that a category is a maintenance task instead, by providing "maintenance" as the third value for any unnamed parameter:
 
  <nowiki>{{Infobox Template/categories
 
  <nowiki>{{Infobox Template/categories
  |cat1=Magical characters!Magical
+
  |Magical characters!Magical
  |cat2=Nonmagical characters!Nonmagical
+
  |Nonmagical characters!Nonmagical
  |cat3=Characters of unknown magicality!''unknown''!maintenance
+
  |Characters of unknown magicality!''unknown''!maintenance
 
}}</nowiki>
 
}}</nowiki>
  
Line 62: Line 63:
  
  
You may leave the "categories" undefined by not specifying any cat# parameters (the category name specifically), or not maintaining proper ordering, so these all have the same result:
+
You may leave the "categories" undefined by not specifying any unnamed parameters (specifically the part left of the 1st separator), or not maintaining proper ordering, so these all have the same result:
 
  <nowiki>{{Infobox Template/categories}}</nowiki>
 
  <nowiki>{{Infobox Template/categories}}</nowiki>
  <nowiki>{{Infobox Template/categories|cat1=}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|}}</nowiki>
  <nowiki>{{Infobox Template/categories|cat=something!something}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|!something}}</nowiki>
  <nowiki>{{Infobox Template/categories|cat1=!something}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|test=something!something}}</nowiki>
  <nowiki>{{Infobox Template/categories|cat1=|cat2=something!something}}</nowiki>
+
  <nowiki>{{Infobox Template/categories||something!something}}</nowiki>
  <nowiki>{{Infobox Template/categories|cat1=something!something|cat1=}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|1=something!something|1=}}</nowiki>
 +
<nowiki>{{Infobox Template/categories|2=something!something}}</nowiki>
  
 
:{{categorizer|category=Noncategorizing templates|label=''none''|nocat=true}}
 
:{{categorizer|category=Noncategorizing templates|label=''none''|nocat=true}}
Line 74: Line 76:
  
 
The '''nocat''' parameter may be used to suppress automatic categorization like this (any value will do):
 
The '''nocat''' parameter may be used to suppress automatic categorization like this (any value will do):
  <nowiki>{{Infobox Template/categories|cat1=Child characters!Child|nocat=true}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|Child characters!Child|nocat=true}}</nowiki>
  
 
This would render the same result as the first example above, but would not automatically categorize under [[:Category:Categorizing templates]].
 
This would render the same result as the first example above, but would not automatically categorize under [[:Category:Categorizing templates]].

Revision as of 13:04, 3 June 2014

This template renders information about another template, a variable list of categories, under which that template may categorize its articles. Depending on the amount of specified categories, this template may also categorize that template under the category that represents that amount. Noncategorizing, (normal) Categorizing or Multi-categorizing.

Parameters

  1. The name of the category that the template may categorize under, with the accompanying value, separated by exclamation mark (no parameter name, multiple parameters allowed, case sensitive)
  • nocat: Whether or not to suppress categorization under the automatically chosen category (defaults to false, which means auto categorization).


Note: the unnamed parameters must be specified in proper order if using their positional numbers, because the first number that is empty/not specified terminates the list. If the list is empty this way, the default 'none' category will be used.

Note: although this template does not limit the amount of possible unnamed parameters, the parent infobox limits to thirty.

Syntax

{{Infobox Template/categories|value!value}}

Warning: this template will often force a table cell to split in two, so do not use it outside table cells! Infoboxes use tables, so in there would be fine.

Examples

Common use includes at least one unnamed parameter to specify the category a template may categorize under, with the value that is required to select that category:

{{Infobox Template/categories|Child characters!Child}}
One: [list all]


You can also specify multiple categories for one template:

{{Infobox Template/categories
 |Child characters!Child
 |Adult characters!Adult
}}
Multiple: [list all]


Additionally, it is possible to specify that a category is a maintenance task instead, by providing "maintenance" as the third value for any unnamed parameter:

{{Infobox Template/categories
 |Magical characters!Magical
 |Nonmagical characters!Nonmagical
 |Characters of unknown magicality!''unknown''!maintenance
}}
Multiple: [list all]


You may leave the "categories" undefined by not specifying any unnamed parameters (specifically the part left of the 1st separator), or not maintaining proper ordering, so these all have the same result:

{{Infobox Template/categories}}
{{Infobox Template/categories|}}
{{Infobox Template/categories|!something}}
{{Infobox Template/categories|test=something!something}}
{{Infobox Template/categories||something!something}}
{{Infobox Template/categories|1=something!something|1=}}
{{Infobox Template/categories|2=something!something}}
none [list all]


The nocat parameter may be used to suppress automatic categorization like this (any value will do):

{{Infobox Template/categories|Child characters!Child|nocat=true}}

This would render the same result as the first example above, but would not automatically categorize under Category:Categorizing templates.