Template:C/doc: Difference between revisions
Template page
More actions
improve |
Fix language-code links to use Wikipedia interwiki prefixes |
||
| (41 intermediate revisions by 10 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 | |||
| 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. | |||
[[: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/> | |||
| 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, | |||
::''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 | |||
::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/> | |||
<includeonly> | | 3sv = x/X/B/G | ||
[[Category:Internal link templates]] | | 3stat = optional- | ||
[[Category:Typing-aid templates]] | | 3type = string | ||
</includeonly> | |||
| 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 | |||
|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 | |||
|usergroup=all | |||
|placement= | |||
|usage-notes= | |||
|type= | |||
|example= | |||
|i18n-method=- | |||
|i18n-desc=The template does not generate any localizable text. With + or - always the namespace (in English) is used. | |||
|i18n-mediawiki-msg= | |||
|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= | |||
|lines= | |||
|shorthand= | |||
|relieson= | |||
}} | |||
== 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. | |||
==== 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: | |||
:<nowiki>[[:Category:{{{1}}}|{{{2|{{{1}}}}}}]]</nowiki> | |||
When the category ''does not exist but has elements assigned'', a "red link" will be generated: | |||
:<nowiki>[[:Category:{{{1}}}|{{{2|{{{1}}}}}}]]</nowiki> | |||
Otherwise if the category <nowiki>{{{1}}}</nowiki> does not exist <u>no link will be generated</u>; | |||
:[[''Category'':{{{1}}}]] or [[''Category'':{{{2}}}]] is displayed | |||
:[[''Category'':<span style="color:red"><nowiki>{{{1}}}</nowiki></span>]] or [[''Category'':<span style="color:red"><nowiki>{{{2}}}</nowiki></span>]] is displayed when {{{3}}} = x | |||
:<span style="background-color:#FEDCBA"><nowiki>{{{1}}}</nowiki></span> or <span style="background-color:#FEDBCA"><nowiki>{{{2}}}</nowiki></span> will get background color when {{{3}}} = X | |||
;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|+}} | |||
{{Commons:Link templates/Category links}} | |||
<includeonly>{{Sandbox other|| | |||
<!-- Categories below this line; interwikis at Wikidata --> | |||
[[Category:Internal link templates|{{PAGENAME}}]] | |||
[[Category:Interwiki link templates|{{PAGENAME}}]] | |||
[[Category:Typing-aid templates|{{PAGENAME}}]] | |||
[[Category:One-letter templates| ]] | |||
}}</includeonly> | |||