Template:C/doc: Difference between revisions
More actions
m Fix Linter errors. |
m +explanation |
||
| Line 10: | Line 10: | ||
Links to a category, either within the Commons or to another Wikipedia and offers additional options for the layout formatting, the linking and more. | 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 <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:”). | 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:”). | ||
Understrokes in the category name are replaced by spaces, a lowercase first character is converted to uppercase. | |||
<nowiki/> | <nowiki/> | ||
| Line 112: | Line 113: | ||
* {{tl|F}} → similar functions for files | * {{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 | * {{Tl|Igen/cat}} for categorizing – different possibilities parametrizable | ||
|setscats= | |setscats= | ||
| Line 124: | Line 128: | ||
Parameter 1 is the category name. Parameter 2 may specify any text do be displayed instead. | 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>. | 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 standard usage is without any prefix and without a namespace. No test occurs, redlinks can result. | ||
| Line 161: | Line 165: | ||
*{{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| | *{{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||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|Cat:I-l-t|B}} produces {{C|Internal link templates|Cat:I-l-t|B}} | ||
Revision as of 08:22, 17 February 2023
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 | 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
- {{ 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 | de | + }} produces Category:Konsonant C
{{Commons:Link templates/Category links}}