Template:C/doc: Difference between revisions
More actions
m format |
m format |
||
| Line 12: | Line 12: | ||
*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 | ||
| Line 42: | Line 42: | ||
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>. | ||
The text string in parameter | The text string in parameter 2 is always displayed as-it-is, with namespace if any is specified. | ||
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. | ||
=== Addressing categories within the commons === | === Addressing categories within the commons === | ||
The standard inclusion is without any prefix and without a namespace. No test occurs, redlinks can result. | |||
When parameter 3 is either X or x, | |||
or when a namespace is encountered, a check for existence is performed.<br> | |||
When the category exists either with or without namespace the following is the existing category. | |||
When the category exists, code is implemented as: | When the category exists, code is implemented as: | ||
| Line 62: | Line 67: | ||
;example | ;example | ||
*<tt><nowiki>{{C}}</nowiki></tt> produces {{C}} | |||
*<tt><nowiki>{{C||error}}</nowiki></tt> produces {{C||error}} | |||
*<tt><nowiki>{{C|Internal link templates}}</nowiki></tt> produces {{C|Internal link templates}} | *<tt><nowiki>{{C|Internal link templates}}</nowiki></tt> produces {{C|Internal link templates}} | ||
*<tt><nowiki>{{C|Internal link templates|}}</nowiki></tt> produces {{C|Internal link templates|}} | *<tt><nowiki>{{C|Internal link templates|}}</nowiki></tt> produces {{C|Internal link templates|}} | ||
*<tt><nowiki>{{C|Internal link templates|C:''display''text}}</nowiki></tt> produces {{C|Internal link templates|C:''display''text}} | *<tt><nowiki>{{C|Internal link templates|C:''display''text}}</nowiki></tt> produces {{C|Internal link templates|C:''display''text}} | ||
| Line 78: | Line 82: | ||
*<tt><nowiki>{{C|Not-existing-cat|3=X}}</nowiki></tt> produces {{C|Not-existing-cat|3=X}} | *<tt><nowiki>{{C|Not-existing-cat|3=X}}</nowiki></tt> produces {{C|Not-existing-cat|3=X}} | ||
*<tt><nowiki>{{C|Not-existing-cat|displayname|X}}</nowiki></tt> produces {{C|Not-existing-cat|displayname|X}} | *<tt><nowiki>{{C|Not-existing-cat|displayname|X}}</nowiki></tt> produces {{C|Not-existing-cat|displayname|X}} | ||
::Not-existing category with elements (difficult to find an example, try one of [[Special:WantedCategories]]) | |||
*<tt><nowiki>{{C|Redes||X}}</nowiki></tt> produces {{C|Redes||X}} | |||
*<tt><nowiki>{{C|redes|Red_Link|x}}</nowiki></tt> produces {{C|redes|Red_Link|x}} | |||
:Single and double namespace prefix: | |||
*<tt><nowiki>{{C|Commons:Multimedia Features/MediaViewer}}</nowiki></tt> produces {{C|Commons:Multimedia Features/Media Viewer}} | |||
*<tt><nowiki>{{C|Category:Commons:Multimedia Features/Media Viewer}}</nowiki></tt> produces {{C|Category:Commons:Multimedia Features/Media Viewer}} | |||
=== Interwiki access === | === Interwiki access === | ||
Revision as of 04:53, 25 February 2015
Links to a category, either within the Commons or to another Wikipedia
Usage
{{C |1= |2= |3= }}
Template parameters
| Parameter | Description | Default | Status | |
|---|---|---|---|---|
1 | category name, with or without a namespace | empty | required | |
2 | link text to display (instead of category name) | param. #1 | optional | |
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
Localization
This template is not intended to be localized.
Usage
The template will display {{{2}}}, or just the category name given as {{{1}}}.
The text string in parameter 2 is always displayed as-it-is, with namespace if any is specified.
The function is different for internal access within the commons, and for interwiki access.
Addressing categories within the commons
The standard inclusion is without any prefix and without a namespace. No test occurs, redlinks can result.
When parameter 3 is either X or x,
or when a namespace is encountered, a check for existence is performed.
When the category exists either with or without namespace the following is 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
- example
- {{C}} produces [[:Category:|]]
- {{C||error}} produces [[:Category:|error]]
- {{C|Internal link templates}} produces Internal link templates
- {{C|Internal link templates|}} produces Internal link templates
- {{C|Internal link templates|C:''display''text}} produces C:displaytext
- {{C|Not-existing-cat}} produces Not-existing-cat
- {{C|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 with elements (difficult to find an example, try one of Special:WantedCategories)
- {{C|Redes||X}} produces Redes
- {{C|redes|Red_Link|x}} produces [[Category:Red_Link]]
- 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