Template:C/doc: Difference between revisions
More actions
m correction |
Fix language-code links to use Wikipedia interwiki prefixes |
||
| (31 intermediate revisions by 7 users not shown) | |||
| Line 1: | Line 1: | ||
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> | |||
{{tsh|catlink}} | |||
{{Heavily used template|3=very}} | |||
<!-- {{Heavily used template}} | |||
{{Use sandbox|testcase= }} --> | |||
{{TemplateBox | {{TemplateBox | ||
|1=1 | | useTemplateData = 1 | ||
|1d=category name | |||
| | | desc-td-en = | ||
| | Links to a category, either within the Commons or to another Wikipedia and offers additional options for the layout formatting, the linking and more. | ||
|2=2 | |||
|2d=link text to display (instead of category name) | In its simplest form <nowiki>{{c|category name}}</nowiki> does the same as <nowiki>[[:Category:category name|category name]]</nowiki>: producing a link to a category displaying just “category name” (without prefixing with the namespace“Category:”). | ||
|2def= | Understrokes in the category name are replaced by spaces, a lowercase first character is converted to uppercase. | ||
|2stat=optional | <nowiki/> | ||
|3=3 | |||
|3d=The 3{{exp|rd}} parameter establishes either | | 1 = 1 | ||
| 1label-en = Category | |||
| 1d-en = category name, with or without a namespace | |||
| 1stat = required | |||
| 1type = wiki-page-name | |||
| 2 = 2 | |||
| 2label-en = Display Text | |||
| 2d-en = link text to display (instead of category name) | |||
| 2def = param. #1 | |||
| 2stat = optional | |||
| 2type = line | |||
| 3 = 3 | |||
| 3label-en = Option | |||
| 3d-en = The 3{{exp|rd}} parameter establishes either | |||
*interwiki access, with any language code, | *interwiki access, with any language code, | ||
::''or'' | ::''or'' | ||
*a link to a category | *a link to a category on Commons, always with check for existence | ||
**existing categories are linked and displayed | **existing categories are linked and displayed | ||
**non-existing categories are not linked, but displayed | **non-existing categories are not linked, but displayed | ||
::(not specified): text is displayed in black color | ::(not specified): text is displayed in black color | ||
:: | ::when <code>3=x</code> (lower case): text is displayed in red color | ||
:: | ::when <code>3=<big>X</big></code> (upper case): display with red background | ||
:''or'' | |||
*when <code>3=<big>B</big></code> (upper case): text is displayed within {{!((}}…{{))!}}-'''b'''rackets | |||
*when <code>3=<big>G</big></code>: <nowiki>[[Category:</nowiki> will be '''g'''enerated; par.2 is sorting option | |||
<nowiki/> | |||
| 3d-td-en = The 3rd parameter establishes either: | |||
* Interwiki access, with any language code, | |||
or | |||
* A link to a category on Commons, always with check for existence | |||
** Existing categories are linked and displayed | |||
** Non-existing categories are not linked, but displayed | |||
*** (not specified): text is displayed in black color | |||
*** 3=x (lower case): text is displayed in red color | |||
*** 3=X (upper case): text is displayed in red color | |||
or | |||
* 3=B (upper case): text is displayed within {{!((}}…{{))!}}-brackets | |||
* 3=G (upper case): “{{!((}}Category:” will be generated; par.2 is sorting option | |||
<nowiki/> | |||
| 3sv = x/X/B/G | |||
| 3stat = optional- | |||
| 3type = string | |||
| 4 = 4 | |||
| 4label-en = Include “Category:” Prefix? | |||
| 4d-en = +/- to precede the category name with the namespace <code>Category:</code> | |||
:'''+''' ("plus" sign) to make <code>Category:</code> a part of the link, | |||
:'''-''' ("minus" sign) to precede <code>Category:</code> as a plain text.<br /> | |||
The +/- parameter can as well be specified with parameter 2 or 3<br /> | |||
(If ''both'' signs are specified, "+" has precedence). | |||
| 4d-td-en = +/- to precede the category name with the namespace “Category:” | |||
; + ("plus" sign) | |||
: to make “Category:” a part of the link, | |||
; - ("minus" sign) | |||
: to precede “Category:” as a plain text. | |||
The +/- parameter can as well be specified with parameter 2 or 3 | |||
(If both signs are specified, “+” has precedence). | |||
<nowiki/> | |||
| 4sv = +/- | |||
| 4stat = optional- | |||
| 4type = string | |||
| 5 = link | |||
| 5label-en = Link? | |||
| 5d-en = Whether to link to the target category page, set to <code>n</code> or <code>none</code> for a plain text result. | |||
| 5d-td-en = Whether to link to the target category page, set to “n” or “none” for a plain text result. | |||
| 5sv = n/none | |||
| 5stat = optional- | |||
| 5type = string | |||
|name=C | |name=C | ||
|desc=Links to a category, either within the Commons or to another Wikipedia | |desc=Links to a category, either within the Commons or to another Wikipedia <br />{{Nobold|and offers additional options for the layout formatting, the linking and more.<br /><br />In its simplest form <code><nowiki>{{c|</nowiki>''category name''<nowiki>}}</nowiki></code> does the same as <code><nowiki>[[:category:</nowiki>''category name''<nowiki>|</nowiki>''category name''<nowiki>]]</nowiki></code> :<br />producing a link to a category displaying just ''[[:category:help|category name]]'' (without prefixing with the namespace“Category:”).}} | ||
|namespace=all | |namespace=all | ||
|usergroup=all | |usergroup=all | ||
| Line 29: | Line 102: | ||
|type= | |type= | ||
|example= | |example= | ||
|i18n-method= | |i18n-method=- | ||
|i18n-desc= | |i18n-desc=The template does not generate any localizable text. With + or - always the namespace (in English) is used. | ||
|i18n-mediawiki-msg= | |i18n-mediawiki-msg= | ||
|seealso= | |seealso = * [[Cat|<code><nowiki>[[Cat:</nowiki> </code>]] → [[:cat:Typing-aid templates]] | ||
* {{tl|cl}}{{0|e}} → {{cl|Typing-aid templates}} | |||
* {{tl|lc}}{{0|e}} → {{lc|Typing-aid templates}} | |||
* {{tl|lcs}} → {{lcs|Typing-aid templates}} | |||
* {{tl|Catseealso}} link to other categories | |||
* {{tl|F}} → similar functions for files | |||
* {{tl|M}} → similar functions for modules | |||
* {{tl|T}} → similar functions for templates | |||
* {{Tl|Igen/cat}} for categorizing – different possibilities parametrizable | |||
|setscats= | |setscats= | ||
|lines= | |lines= | ||
| Line 40: | Line 124: | ||
== Usage == | == Usage == | ||
=== Standard usage === | |||
Displays a link to a category name. | |||
Parameter 1 is the category name. Parameter 2 may specify any text do be displayed instead. | |||
The template will display <nowiki>{{{2}}}</nowiki>, or just the category name given as <nowiki>{{{1}}}</nowiki> (but with replacing<br />understrokes in the category name by spaces, and converting a lowercase first character to uppercase). | |||
The standard usage is without any prefix and without a namespace. No test occurs, redlinks can result. | |||
The text string in parameter 2 is always displayed as-it-is, with namespace if any is specified. | |||
=== Extended usage === | |||
The function is different for internal access within the commons, and for interwiki access. | The function is different for internal access within the commons, and for interwiki access. | ||
=== | ==== Within the commons ==== | ||
The template can generate 5 different displays, one for an existing and four for a not-existing category. | |||
When parameter 3 is either X or x, | |||
or when a namespace is encountered, a check for existence is performed.<br /> | |||
This can avoid the generation of a redlink to a not-existing category. | |||
When later the category is defined, the display occurs like standard as above. | |||
When the category exists either with or without namespace the following explanation depends the existing category. | |||
When the category exists, code is implemented as: | When the category exists, code is implemented as: | ||
| Line 59: | Line 159: | ||
; | ;examples: | ||
* | *{{Tle|T=C}} produces {{C}} | ||
* | *{{Tle|T=C||error}} produces {{C||error}} | ||
* | |||
*{{Tle|T=C|Internal link templates}} produces {{C|Internal link templates}} | |||
*{{Tle|T=C|internal_link_templates|}} produces {{C|internal_link_templates|}} | |||
*{{Tle|T=C|Internal link templates||B}} produces {{C|Internal link templates||B}} | |||
*{{Tle|T=C|Internal link templates|Cat:I-l-t|B}} produces {{C|Internal link templates|Cat:I-l-t|B}} | |||
*{{Tle|T=C|Internal link templates|C:''display''text}} produces {{C|Internal link templates|C:''display''text}} | |||
# {{Tle|T=C|Not-existing-cat}} produces {{C|Not-existing-cat}}<br /><!-- | |||
-->{{Tle|T=C|Not-existing-cat|display}} produces {{C|Not-existing-cat|display}} | |||
# {{Tle|T=C|Category:Not-existing-cat}} produces {{C|Category:Not-existing-cat}}<br /><!-- | |||
-->{{Tle|T=C|Category:Not-existing-cat|display}} produces {{C|Category:Not-existing-cat|display}} | |||
# {{Tle|T=C|Not-existing-cat|p2=3|x}} produces {{C|Not-existing-cat|3=x}}<br /><!-- | |||
-->{{Tle|T=C|Not-existing-cat|display-cat|x}} produces {{C|Not-existing-cat|display-cat|x}} | |||
# {{Tle|T=C|Not-existing-cat|p2=3|X}} produces {{C|Not-existing-cat|3=X}}<br /><!-- | |||
-->{{Tle|T=C|Not-existing-cat|displayname|X}} produces {{C|Not-existing-cat|displayname|X}} | |||
:Not-existing category containing elements (difficult to find an example, try one of [[Special:WantedCategories]]) | |||
::{{Tle|T=C|Redes||X}} produces {{C|Redes||X}} | |||
::{{Tle|T=C|redes|Red_Link|x}} produces {{C|redes|Red_Link|x}} | |||
:Single and double namespace prefix: | |||
*{{Tle|T=C|Commons:Multimedia Features/MediaViewer}} produces {{C|Commons:Multimedia Features/Media Viewer}} | |||
*{{Tle|T=C|Category:Commons:Multimedia Features/Media Viewer}} produces {{C|Category:Commons:Multimedia Features/Media Viewer}} | |||
* | Link parameter: | ||
* {{Tle|T=C|Internal link templates|p2=link|n}} produces {{C|Internal link templates|link=n}}<br/><!-- | |||
-->{{Tle|T=C|Internal link templates|p2=link|none}} produces {{C|Internal link templates|link=none}} | |||
* | * {{Tle|T=C|Category:Internal link templates|p2=link|n}} produces {{C|Category:Internal link templates|link=n}}<br/><!-- | ||
-->{{Tle|T=C|Category:Internal link templates|p2=link|none}} produces {{C|Category:Internal link templates|link=none}} | |||
==== Interwiki access ==== | |||
It is not possible to check for existence in other Wikipedias.<br />The link is always established, whether the category exists or not. | |||
=== | *{{Tle|T=C|Main||w:en}} or {{Tle|T=C|Main|p2=3|w:en}} produces {{C|Main||w:en}} | ||
*{{Tle|T=C|Wikipedia:Hilfe|German help pages|w:de}} produces {{C|Wikipedia:Hilfe|German help pages|w:de}} | |||
*{{Tle|T=C|Accueil|Catégorie:Accueil|w:fr}} produces {{C|Accueil|Catégorie:Accueil|w:fr}} | |||
*{{Tle|T=C|Kangxi radicals||wiktionary}} produces {{C|Kangxi radicals||wiktionary}} | |||
*{{Tle|T=C|Wikcionario:Apéndices|Categoría:Apéndices|wiktionary:es}} produces {{C|Wikcionario:Apéndices|Categoría:Apéndices|wiktionary:es}} | |||
* | ==== Namespace display ==== | ||
* | *{{Tle|T=C|A|-}} produces {{C|A|-}} | ||
* | *{{Tle|T=C|B|+}} produces {{C|B|+}} | ||
*{{Tle|T=C|C|Konsonant C|w:de|+}} produces {{C|C|Konsonant C|w:de|+}} | |||
<includeonly> | {{Commons:Link templates/Category links}} | ||
<includeonly>{{Sandbox other|| | |||
<!-- Categories below this line; interwikis at Wikidata --> | |||
[[Category:Internal link templates|{{PAGENAME}}]] | [[Category:Internal link templates|{{PAGENAME}}]] | ||
[[Category:Interwiki link templates|{{PAGENAME}}]] | [[Category:Interwiki link templates|{{PAGENAME}}]] | ||
[[Category:Typing-aid templates|{{PAGENAME}}]] | [[Category:Typing-aid templates|{{PAGENAME}}]] | ||
</includeonly> | [[Category:One-letter templates| ]] | ||
}}</includeonly> | |||
Latest revision as of 18:44, 12 August 2026
Links to a category, either within the Commons or to another Wikipedia
and offers additional options for the layout formatting, the linking and more.
In its simplest form {{c|category name}} does the same as [[:category:category name|category name]] :
producing a link to a category displaying just category name (without prefixing with the namespace“Category:”).
Usage
{{C |1= |2= }}
Template parameters
| Parameter | Description | Default | Status | |
|---|---|---|---|---|
1 | Category | category name, with or without a namespace | empty | required |
2 | Display Text | link text to display (instead of category name) | param. #1 | optional |
3 | Option | The 3rd parameter establishes either
| empty | optional |
4 | Include “Category:” Prefix? | +/- to precede the category name with the namespace Category:
The +/- parameter can as well be specified with parameter 2 or 3 | empty | optional |
link | Link? | Whether to link to the target category page, set to n or none for a plain text result. | empty | optional |
|
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard. Existing template documentation Newly created template documentation and imports Wikipedia's help about TemplateData • Commons-specific information Links to a category, either within the Commons or to another Wikipedia and offers additional options for the layout formatting, the linking and more. In its simplest form {{c|category name}} does the same as [[:Category:category name|category name]]: producing a link to a category displaying just “category name” (without prefixing with the namespace“Category:”). Understrokes in the category name are replaced by spaces, a lowercase first character is converted to uppercase.
| ||||||||||||||||||||||||||||||
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
See also
[[Cat:→ cat:Typing-aid templates- {{Cl}} → Category:Typing-aid templates
- {{Lc}} → Category:Typing-aid templates (edit|talk|history|links|watch|logs)
- {{Lcs}} →
- {{Catseealso}} link to other categories
- {{F}} → similar functions for files
- {{M}} → similar functions for modules
- {{T}} → similar functions for templates
- {{Igen/cat}} for categorizing – different possibilities parametrizable
Localization
This template is not intended to be localized.
The template does not generate any localizable text. With + or - always the namespace (in English) is used.
Usage
Standard usage
Displays a link to a category name. Parameter 1 is the category name. Parameter 2 may specify any text do be displayed instead.
The template will display {{{2}}}, or just the category name given as {{{1}}} (but with replacing
understrokes in the category name by spaces, and converting a lowercase first character to uppercase).
The standard usage is without any prefix and without a namespace. No test occurs, redlinks can result.
The text string in parameter 2 is always displayed as-it-is, with namespace if any is specified.
Extended usage
The function is different for internal access within the commons, and for interwiki access.
Within the commons
The template can generate 5 different displays, one for an existing and four for a not-existing category.
When parameter 3 is either X or x,
or when a namespace is encountered, a check for existence is performed.
This can avoid the generation of a redlink to a not-existing category.
When later the category is defined, the display occurs like standard as above.
When the category exists either with or without namespace the following explanation depends the existing category.
When the category exists, code is implemented as:
- [[:Category:{{{1}}}|{{{2|{{{1}}}}}}]]
When the category does not exist but has elements assigned, a "red link" will be generated:
- [[:Category:{{{1}}}|{{{2|{{{1}}}}}}]]
Otherwise 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
- examples
- {{ C | Internal link templates }} produces Internal link templates
- {{ C | internal_link_templates }} produces internal_link_templates
- {{ C | Internal link templates | B }} produces [[Internal link templates]]
- {{ C | Internal link templates | Cat:I-l-t | B }} produces [[Cat:I-l-t]]
- {{ C | Internal link templates | C:displaytext }} produces C:displaytext
- {{ C | Not-existing-cat }} produces Not-existing-cat
{{ C | Not-existing-cat | display }} produces display - {{ C | Category:Not-existing-cat }} produces Category:Not-existing-cat
{{ C | Category:Not-existing-cat | display }} produces 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
- Not-existing category containing elements (difficult to find an example, try one of Special:WantedCategories)
- Single and double namespace prefix:
- {{ C | Commons:Multimedia Features/MediaViewer }} produces Commons:Multimedia Features/Media Viewer
- {{ C | Category:Commons:Multimedia Features/Media Viewer }} produces Category:Commons:Multimedia Features/Media Viewer
Link parameter:
- {{ C | Internal link templates | link = n }} produces Internal link templates
{{ C | Internal link templates | link = none }} produces Internal link templates - {{ C | Category:Internal link templates | link = n }} produces Category:Internal link templates
{{ C | Category:Internal link templates | link = none }} produces Category:Internal link templates
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 | w:en }} or {{ C | Main | 3 = w:en }} produces Main
- {{ C | Wikipedia:Hilfe | German help pages | w:de }} produces German help pages
- {{ C | Accueil | Catégorie:Accueil | w:fr }} produces Catégorie:Accueil
- {{ C | Kangxi radicals | wiktionary }} produces Kangxi radicals
- {{ C | Wikcionario:Apéndices | Categoría:Apéndices | wiktionary:es }} produces Categoría:Apéndices
Namespace display
- {{ C | A | - }} produces Category:A
- {{ C | B | + }} produces Category:B
- {{ C | C | Konsonant C | w:de | + }} produces Category:Konsonant C
{{Commons:Link templates/Category links}}