Template:C/doc: Difference between revisions
More actions
Because it is a help page, it is now explained WHAT it does. Hope you are fine with that proposal. |
Enable generating TemplateData from {{TemplateBox}} |
||
| Line 1: | Line 1: | ||
{{ | <!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> | ||
{{tsh|catlink}} | |||
{{Heavily used template}} | |||
<!-- {{Heavily used template}} | <!-- {{Heavily used template}} | ||
{{Use sandbox|testcase= }} -->{{TemplateBox | {{Use sandbox|testcase= }} --> | ||
{{TemplateBox/sandbox | |||
| useTemplateData = 1 | |||
| 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. | |||
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 “Category:” before). | |||
<nowiki/> | |||
|1=1 | |1=1 | ||
| 1label-en = Category | |||
|1d=category name, with or without a namespace | |1d=category name, with or without a namespace | ||
|1stat=required | |1stat=required | ||
| 1type = wiki-page-name | |||
|2=2 | |2=2 | ||
| 2label-en = Display Text | |||
|2d=link text to display (instead of category name) | |2d=link text to display (instead of category name) | ||
|2def=param. #1 | |2def=param. #1 | ||
|2stat=optional | |2stat=optional | ||
| 2type = line | |||
|3=3 | |3=3 | ||
| 3label-en = Option | |||
|3d=The 3{{exp|rd}} parameter establishes either | |3d=The 3{{exp|rd}} parameter establishes either | ||
*interwiki access, with any language code, | *interwiki access, with any language code, | ||
| Line 21: | Line 38: | ||
::when <tt>3=<big>X</big></tt> (upper case): display with red background | ::when <tt>3=<big>X</big></tt> (upper case): display with red background | ||
:''or'' | :''or'' | ||
*when <tt>3=<big>B</big></tt> (upper case): text is displayed within {{!((}}… | *when <tt>3=<big>B</big></tt> (upper case): text is displayed within {{!((}}…{{))!}}-'''b'''rackets | ||
*when <tt>3=<big>G</big></tt>: <nowiki>[[Category:</nowiki> will be '''g'''enerated; par.2 is sorting option | *when <tt>3=<big>G</big></tt>: <nowiki>[[Category:</nowiki> will be '''g'''enerated; par.2 is sorting option | ||
| | |||
| 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 | |||
| 3sv = x/X/B/G | |||
|3stat=optional- | |3stat=optional- | ||
| 3type = string | |||
|4=4 | |4=4 | ||
| 4label-en = Include “Category:” Prefix? | |||
|4d=+/- to precede the category name with the namespace <code>Category:</code> | |4d=+/- to precede the category name with the namespace <code>Category:</code> | ||
:'''+''' ("plus" sign) to make <tt>Category:</tt> a part of the link, | :'''+''' ("plus" sign) to make <tt>Category:</tt> a part of the link, | ||
| Line 31: | Line 66: | ||
The +/- parameter can as well be specified with parameter 2 or 3<br> | The +/- parameter can as well be specified with parameter 2 or 3<br> | ||
(If ''both'' signs are specified, "+" has precedence). | (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). | |||
| 4sv=+/- | |||
|4stat=optional- | |4stat=optional- | ||
| 4type = string | |||
|name=C | |name=C | ||
|desc= | |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 “Category:” before).}} | ||
|namespace=all | |namespace=all | ||
|usergroup=all | |usergroup=all | ||
| Line 141: | Line 187: | ||
*{{Tle|T=C|B|+}} produces {{C|B|+}} | *{{Tle|T=C|B|+}} produces {{C|B|+}} | ||
*{{Tle|T=C|C|Konsonant C|de|+}} produces {{C|C|Konsonant C|de|+}} | *{{Tle|T=C|C|Konsonant C|de|+}} produces {{C|C|Konsonant C|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}}]] | ||
[[Category:One-letter templates| ]] | [[Category:One-letter templates| ]] | ||
</includeonly> | }}</includeonly> | ||
Revision as of 15:13, 11 June 2021
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}}}.
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
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}}