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

From Twinsuniverse
Jump to: navigation, search
m
(added infobox)
 
(7 intermediate revisions by the same user not shown)
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">
+
   <tr><td colspan="2">{{ <!-- one or more arguments -->
  {{ <!-- one or more arguments -->
+
   #vardefine: arg | 1 }}{{
   #vardefine: cat | 1 }}{{
+
   #while: | {{{ {{#var: arg }}|}}}
   #while: | {{{ cat{{#var: cat }} |}}}
+
 
   |<nowiki/>
 
   |<nowiki/>
* {{categorizer|category={{{cat{{#var: cat }}}}}|label={{{val{{#var: cat }}|}}}|nocat=false}}{{
+
* {{#if: {{#explode:{{{ {{#var: arg }}|}}}|!|0}}
     #vardefine: cat | {{#expr: {{#var: cat }} + 1 }}}}
+
    |{{categorizer|category={{#explode:{{{ {{#var: arg }}|}}}|!|0}}
 +
      |catlabel={{
 +
        #ifeq:{{#explode:{{{ {{#var: arg }}|}}}|!|2}}|
 +
        |{{#ifeq: {{#explode:{{{ {{#var: arg }}|}}}|!|1}}|||category}}
 +
        |{{#explode:{{{ {{#var: arg }}|}}}|!|2}}}}
 +
      |label={{#explode:{{{ {{#var: arg }}|}}}|!|1}}|nocat=true}}
 +
    |{{#explode:{{{ {{#var: arg }}|}}}|!|1}} }}{{
 +
     #vardefine: arg | {{#expr: {{#var: arg }} + 1 }}}}
 
   }}
 
   }}
 
|<!-- no arguments -->
 
|<!-- no arguments -->
 
   {{categorizer|category=Noncategorizing templates|label=''none''|nocat={{{nocat|false}}}}}
 
   {{categorizer|category=Noncategorizing templates|label=''none''|nocat={{{nocat|false}}}}}
}}</includeonly><noinclude>
+
}}</includeonly><noinclude>{{Infobox Template
 +
|purpose=infobox
 +
|singletag=no
 +
|multiline=optional
 +
|gamerelated=no
 +
|suppressible=recursively
 +
|choice=multiple
 +
|cat1=Noncategorizing templates!''none''
 +
|cat2=Categorizing templates!''one''
 +
|cat3=Multi-categorizing templates!''multiple''
 +
|var1=arg
 +
}}
 +
 
 
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. [[:Category:Noncategorizing templates|Noncategorizing]], (normal) [[:Category:Categorizing templates|Categorizing]] or [[:Category:Multi-categorizing templates|Multi-categorizing]].
 
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. [[:Category:Noncategorizing templates|Noncategorizing]], (normal) [[:Category:Categorizing templates|Categorizing]] or [[:Category:Multi-categorizing templates|Multi-categorizing]].
  
 
==Parameters==
 
==Parameters==
* '''cat1''': The name of the category the template may categorize under (parameter allows duplicates with increasing number; cat1, cat2, cat3, etc)
+
# A category specification for the template, in the following format (no parameter name, multiple parameters allowed, case sensitive)
* '''val1''': The value that the template requires for categorization under the category specified by '''cat1''' (parameter allows duplicates with increasing number; val1, val2, val3, etc)
+
## The ''category name'' of the category the template may categorize under (if empty string, only the ''value'' part is displayed)
 +
## An ''exclamation mark'' (required as separator)
 +
## The ''value'' that is required to select this category (optional, required if there is no ''category name'')
 +
## An ''exclamation mark'' (required as separator)
 +
## A ''custom string'' to use on the category link (optional, defaults to "category" if a ''value'' is also specified)
 
* '''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 parameter pairs must be specified in pairs and in proper order, because the first empty/not specified pair 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#/val# parameter pairs, the parent infobox limits to thirty pairs.''
+
'''''Note:''' although this template does not limit the amount of possible unnamed parameters, the parent infobox limits to thirty.''
 
+
'''''Note:''' if no cat#/val# parameter pair is detected, the default 'none' category will be used. These parameters always require a number, even if they are the only pair.''
+
  
 
==Syntax==
 
==Syntax==
  <nowiki>{{Infobox Template/categories|cat1=value|val1=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 pair of '''cat1''' and '''val1''' parameters to specify the category a template may categorize under:
+
Common use includes at least one unnamed parameter to specify the category a template will categorize its pages under:
  <nowiki>{{Infobox Template/categories|cat1=Child characters|val1=Child}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|Characters}}</nowiki>
  
 
:{{categorizer|category=Categorizing templates|label=One:|nocat=true}}
 
:{{categorizer|category=Categorizing templates|label=One:|nocat=true}}
:*{{categorizer|category=Child characters|label=Child|nocat=true}}
+
:*{{categorizer|category=Characters|catlabel=|label=|nocat=true}}
  
  
You can also specify multiple categories for one template:
+
You can also specify multiple categories for the same template, if they are all non-optional:
  <nowiki>{{Infobox Template/categories|cat1=Child characters|val1=Child|cat2=Adult characters|val2=Adult}}</nowiki>
+
  <nowiki>{{Infobox Template/categories
 +
|Characters
 +
|Adult characters
 +
|Characters of unknown gender
 +
}}</nowiki>
  
 
:{{categorizer|category=Multi-categorizing templates|label=Multiple:|nocat=true}}
 
:{{categorizer|category=Multi-categorizing templates|label=Multiple:|nocat=true}}
:*{{categorizer|category=Child characters|label=Child|nocat=true}}
+
:*{{categorizer|category=Characters|catlabel=|label=|nocat=true}}
:*{{categorizer|category=Adult characters|label=Adult|nocat=true}}
+
:*{{categorizer|category=Adult characters|catlabel=|label=|nocat=true}}
 +
:*{{categorizer|category=Characters of unknown gender|catlabel=|label=|nocat=true}}
 +
 
 +
 
 +
If however, the template allows a choice between the categories, a value may be specified that is used to select each category. This would logically only apply if there are more than one categories, but this is no restriction. You can do this by specifying a second value for any unnamed parameter, separated by exclamation mark:
 +
<nowiki>{{Infobox Template/categories
 +
|Child characters!child
 +
|Adult characters!adult
 +
|Characters of unknown age!''unknown''
 +
}}</nowiki>
 +
 
 +
:{{categorizer|category=Multi-categorizing templates|label=Multiple:|nocat=true}}
 +
:*{{categorizer|category=Child characters|catlabel=category|label=child|nocat=true}}
 +
:*{{categorizer|category=Adult characters|catlabel=category|label=adult|nocat=true}}
 +
:*{{categorizer|category=Characters of unknown age|catlabel=category|label=''unknown''|nocat=true}}
 +
 
 +
 
 +
It is possible to customize the text on the link, for instance "maintenance", by specifying a third value for any unnamed parameter (any value is possible), also separated by exclamation mark:
 +
<nowiki>{{Infobox Template/categories
 +
|Child characters!child
 +
|Adult characters!adult
 +
|Characters of unknown age!''unknown''!maintenance
 +
}}</nowiki>
 +
 
 +
:{{categorizer|category=Multi-categorizing templates|label=Multiple:|nocat=true}}
 +
:*{{categorizer|category=Child characters|catlabel=category|label=child|nocat=true}}
 +
:*{{categorizer|category=Adult characters|catlabel=category|label=adult|nocat=true}}
 +
:*{{categorizer|category=Characters of unknown age|catlabel=maintenance|label=''unknown''|nocat=true}}
 +
 
 +
 
 +
To be able to customize the text on the link if there is no second value like in the first example above, you just leave the second value empty:
 +
<nowiki>{{Infobox Template/categories
 +
|Characters!!People
 +
}}</nowiki>
 +
 
 +
:{{categorizer|category=Categorizing templates|label=One:|nocat=true}}
 +
:*{{categorizer|category=Characters|catlabel=People|label=|nocat=true}}
 +
 
 +
 
 +
Some templates may not know in advance which categories it will categorize under, in which case the category name should be empty and the second value used to describe how the template gets the category name (for instance one of its parameters):
 +
<nowiki>{{Infobox Template/categories
 +
|!''parameterName''
 +
}}</nowiki>
 +
 
 +
:{{categorizer|category=Categorizing templates|label=One:|nocat=true}}
 +
:*''parameterName''
  
  
You may leave the "categories" undefined by not specifying cat#/val# parameter pairs (the cat parameter 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 (i.e. completely empty), 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=|val1=}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|}}</nowiki>
  <nowiki>{{Infobox Template/categories|cat=something|val=something}}</nowiki>
+
<nowiki>{{Infobox Template/categories|1=}}</nowiki>
  <nowiki>{{Infobox Template/categories|cat1=|val1=something}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|test=something}}</nowiki>
  <nowiki>{{Infobox Template/categories|cat1=|val1=|cat2=something|val2=something}}</nowiki>
+
  <nowiki>{{Infobox Template/categories||something}}</nowiki>
  <nowiki>{{Infobox Template/categories|cat1=something|val1=something|cat1=|val1=}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|1=something|1=}}</nowiki>
 +
  <nowiki>{{Infobox Template/categories|2=something}}</nowiki>
  
 
:{{categorizer|category=Noncategorizing templates|label=''none''|nocat=true}}
 
:{{categorizer|category=Noncategorizing templates|label=''none''|nocat=true}}
Line 63: Line 133:
  
 
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|val1=Child|nocat=true}}</nowiki>
+
  <nowiki>{{Infobox Template/categories|Characters|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]].
  
[[Category:Categorizers|template]]
 
 
</noinclude>
 
</noinclude>

Latest revision as of 18:43, 6 June 2014

Infobox Template/categories
Purpose

Infobox [list all]

Single tag

No [list all]

Multi-line

Optional [list all]

Protected

No [list all]

Game related

No [list all]

Categorization
Suppressible

Recursively [list all]

Choice

Multiple categories [list all]

Categories

Multiple: [list all]

Variables
Names

One: [list all]

  • arg  (free for reuse)
Subpages

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. A category specification for the template, in the following format (no parameter name, multiple parameters allowed, case sensitive)
    1. The category name of the category the template may categorize under (if empty string, only the value part is displayed)
    2. An exclamation mark (required as separator)
    3. The value that is required to select this category (optional, required if there is no category name)
    4. An exclamation mark (required as separator)
    5. A custom string to use on the category link (optional, defaults to "category" if a value is also specified)
  • 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 will categorize its pages under:

{{Infobox Template/categories|Characters}}
One: [list all]


You can also specify multiple categories for the same template, if they are all non-optional:

{{Infobox Template/categories
 |Characters
 |Adult characters
 |Characters of unknown gender
}}
Multiple: [list all]


If however, the template allows a choice between the categories, a value may be specified that is used to select each category. This would logically only apply if there are more than one categories, but this is no restriction. You can do this by specifying a second value for any unnamed parameter, separated by exclamation mark:

{{Infobox Template/categories
 |Child characters!child
 |Adult characters!adult
 |Characters of unknown age!''unknown''
}}
Multiple: [list all]


It is possible to customize the text on the link, for instance "maintenance", by specifying a third value for any unnamed parameter (any value is possible), also separated by exclamation mark:

{{Infobox Template/categories
 |Child characters!child
 |Adult characters!adult
 |Characters of unknown age!''unknown''!maintenance
}}
Multiple: [list all]


To be able to customize the text on the link if there is no second value like in the first example above, you just leave the second value empty:

{{Infobox Template/categories
 |Characters!!People
}}
One: [list all]


Some templates may not know in advance which categories it will categorize under, in which case the category name should be empty and the second value used to describe how the template gets the category name (for instance one of its parameters):

{{Infobox Template/categories
 |!''parameterName''
}}
One: [list all]
  • parameterName


You may leave the "categories" undefined by not specifying any unnamed parameters (i.e. completely empty), or not maintaining proper ordering, so these all have the same result:

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


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

{{Infobox Template/categories|Characters|nocat=true}}

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