Difference between revisions of "Template:C"
(Created page with "{{#switch:{{{3|}}}|X|x||={{#ifexist:Category:{{{1}}}|[[:Category:{{{1}}}|{{#if:{{{2|}}}|{{{2}}}|{{{1}}}}}]]|{{#ifeq:{{{3|}}}|X|<span style="background-color:#FEDBCA">{{#if:{{{...") |
m (Protected "Template:C" ([edit=sysop] (indefinite) [move=sysop] (indefinite))) |
(No difference)
|
Latest revision as of 18:59, 6 September 2012
[[Category:{{{1}}}]]
Links to a category, either within the Commons or to another Wikipedia
Contents
Usage
{{C|1=|2=|3=}}
Parameters
Parameter name | Description | Default value | required or optional?
|
---|---|---|---|
parameter #1 (1) | category name | empty | required |
parameter #2 (2) | link text to display (instead of category name) | empty | optional |
parameter #3 (3) | The 3rd parameter establishes either
|
empty | optional |
Additional information
The template is intended to be used in the following namespaces: all namespaces
The template is intended to be used by the following user groups: all users
Usage
The template will display {{{2}}}, or just the category name given as {{{1}}}.
The function is different for internal access within the commons, and for interwiki access.
Adressing categories within the commons
First of all, always a check for existence is performed.
When the category exists, code is implemented as:
- [[:Category:{{{1}}}|{{{2|{{{1}}}}}}]]
If the category {{{1}}} does not exist no link will be generated;
- [[Category:{{{1}}}]] or [[Category:{{{2}}}]] is displayed
- [[Category:{{{1}}}]] or [[Category:{{{2}}}]] is displayed when {{{3}}} = x
- {{{1}}} or {{{2}}} will get background color when {{{3}}} = X
- example
- {{C|Internal link templates}} produces [[Category:Internal link templates]]
- {{C|Internal link templates|}} produces [[Category:Internal link templates]]
- {{C|Internal link templates|C:''display''text}} produces [[Category:C:displaytext]]
- {{C|not-existing-cat}} produces [[Category:not-existing-cat]]
- {{C|not-existing-cat|display}} produces [[Category:display]]
- {{C|not-existing-cat|3=x}} produces [[Category:not-existing-cat]]
- {{C|not-existing-cat|display-cat|x}} produces [[Category:display-cat]]
- {{C|not-existing-cat|3=X}} produces not-existing-cat
- {{C|not-existing-cat|displayname|X}} produces displayname
Interwiki access
It is not possible to check for existence in other Wikipedias.
The link is always established, whether the category exists or not.
- {{C|Main||en}} or {{C|Main|3=en}} produces Main
- {{C|Wikipedia:Hilfe|German help pages|de}} produces German help pages
- {{C|Accueil|Catégorie:Accueil|fr}} produces Catégorie:Accueil
The above documentation is transcluded from Template:C/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories and interwikis to the /doc subpage. Subpages of this template. |