This page is semi-protected against editing.

Template:C

From Wikimedia Commons, the free media repository
(Redirected from Template:Catlink)
Jump to navigation Jump to search

[[:Category:|]]

Template documentationview · edit · history · purge ]
This documentation is transcluded from Template:C/doc.

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

ParameterDescriptionDefaultStatus
1Categorycategory name, with or without a namespaceemptyrequired
2Display Textlink text to display (instead of category name)param. #1optional
3OptionThe 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
when 3=x (lower case): text is displayed in red color
when 3=X (upper case): display with red background
or
  • when 3=B (upper case): text is displayed within -brackets
  • when 3=G: [[Category: will be generated; par.2 is sorting option
emptyoptional
4Include “Category:” Prefix?+/- 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).
emptyoptional
linkLink?Whether to link to the target category page, set to n or none for a plain text result.emptyoptional
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData

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
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either ‎useTemplateData=1 or ‎useTemplateData=only on the ‎/doc subpage and transcluding it with {{Documentation}} into the template. ‎<nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.

Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw ‎<templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.


Wikipedia's help about TemplateDataCommons-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.

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Category1

category name, with or without a namespace

Page namerequired
Display Text2

link text to display (instead of category name)

Default
param. #1
Lineoptional
Option3

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

Suggested values
x X B G
Stringoptional
Include “Category:” Prefix?4

+/- 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).

Suggested values
+ -
Stringoptional
Link?link

Whether to link to the target category page, set to “n” or “none” for a plain text result.

Suggested values
n none
Stringoptional

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


  • {{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 }} produces [[:Category:|]]
  • {{ Cerror }} produces [[:Category:|error]]



  1. {{ CNot-existing-cat }} produces Not-existing-cat
    {{ CNot-existing-catdisplay }} produces display
  2. {{ CCategory:Not-existing-cat }} produces Category:Not-existing-cat
    {{ CCategory:Not-existing-catdisplay }} produces display
  3. {{ CNot-existing-cat3 = x }} produces [[Category:Not-existing-cat]]
    {{ CNot-existing-catdisplay-catx }} produces [[Category:display-cat]]
  4. {{ CNot-existing-cat3 = X }} produces Not-existing-cat
    {{ CNot-existing-catdisplaynameX }} produces displayname
Not-existing category containing elements (difficult to find an example, try one of Special:WantedCategories)
{{ CRedesX }} produces Redes
{{ CredesRed_Linkx }} produces Red_Link


Single and double namespace prefix:

Link parameter:

  • {{ CInternal link templateslink = n }} produces Internal link templates
    {{ CInternal link templateslink = none }} produces Internal link templates
  • {{ CCategory:Internal link templateslink = n }} produces Category:Internal link templates
    {{ CCategory:Internal link templateslink = 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.

  • {{ CMainen }} or {{ CMain3 = en }} produces Main
  • {{ CWikipedia:HilfeGerman help pagesde }} produces German help pages
  • {{ CAccueilCatégorie:Accueilfr }} produces Catégorie:Accueil
  • {{ CKangxi radicalswiktionary }} produces Kangxi radicals
  • {{ CWikcionario:ApéndicesCategoría:Apéndiceswiktionary:es }} produces Categoría:Apéndices

Namespace display

[edit subpage]

Code Result Equivalent
Categories existing on Commons

{{C|Link templates}}

Link templates[[:Category:Link templates|Link templates]]

{{C|Link templates|Display name}}

Display name[[:Category:Link templates|Display name]]

{{C|Link templates|3=X}}

Link templates[[:Category:Link templates|Link templates]]

{{C|Link templates|3=x}}

Link templates[[:Category:Link templates|Link templates]]

{{C|Link templates|3=B}}

[[Link templates]](special output display)

{{C|Link templates|3=-}}

Category:Link templates(special output display)

{{C|Link templates|3=+}}

Category:Link templates(special output display)

{{Cl|Link templates}}

Category:Link templates[[:Category:Link templates]]
Categories NOT existing on Commons

{{C|Category name}}

Category name[[:Category:category name|category name]]

{{C|Category name|Display name}}

Display name[[:Category:Category name|Display name]]

{{C|Category name|3=X}}

Category name(special output display)

{{C|Category name|3=x}}

Category name(special output display)

{{C|PowerHaus|3=X}}

PowerHaus(not-empty not-existing category)

{{C|PowerHaus|3=x}}

PowerHaus(not-empty not-existing category)

{{C|Category name|3=x}}

[[Category:Category name]](special output display)

{{Cl|Category name}}

Category:Category name[[:Category:Category name]]
Categories on other wikis (e.g. below on Portuguese Wikipedia), existence not tested

{{C|!Predefinições por função|Predefs|pt}}

Predefs[[:pt:Category:!Predefinições por função|Predefs]]

{{C|XyzXyz||pt}}

XyzXyz[[:pt:Category:XyzXyz]]