Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:C/doc: Difference between revisions

Template page
m -link
m Fix Linter errors.
Line 35: Line 35:
**non-existing categories are not linked, but displayed
**non-existing categories are not linked, but displayed
::(not specified): text is displayed in black color
::(not specified): text is displayed in black color
::when <tt>3=x</tt> (lower case): text is displayed in red color
::when <code>3=x</code> (lower case): text is displayed in red color
::when <tt>3=<big>X</big></tt> (upper case): display with red background
::when <code>3=<big>X</big></code> (upper case): display with red background
:''or''  
:''or''  
*when <tt>3=<big>B</big></tt> (upper case): text is displayed within {{!((}}…{{))!}}-'''b'''rackets  
*when <code>3=<big>B</big></code> (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 <code>3=<big>G</big></code>: <nowiki>[[Category:</nowiki> will be '''g'''enerated; par.2 is sorting option
<nowiki/>
<nowiki/>


Line 64: Line 64:


| 4d-en = +/-  to precede the category name with the namespace <code>Category:</code>
| 4d-en = +/-  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 <code>Category:</code> a part of the link,
:'''-''' ("minus" sign) to precede <tt>Category:</tt> as a plain text.<br>
:'''-''' ("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>  
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).


Line 93: Line 93:


|name=C
|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>&nbsp;:<br>producing a link to a category displaying just ''[[:category:help|category name]]'' (without prefixing with the namespace“Category:”).}}
|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>&nbsp;:<br />producing a link to a category displaying just ''[[:category:help|category name]]'' (without prefixing with the namespace“Category:”).}}


|namespace=all
|namespace=all
Line 104: Line 104:
|i18n-desc=The template does not generate any localizable text. With + or - always the namespace (in English) is used.
|i18n-desc=The template does not generate any localizable text. With + or - always the namespace (in English) is used.
|i18n-mediawiki-msg=
|i18n-mediawiki-msg=
|seealso = * [[Cat|<tt><nowiki>[[Cat:</nowiki>&nbsp;</tt>]] → [[:cat:Typing-aid templates]]
|seealso = * [[Cat|<code><nowiki>[[Cat:</nowiki>&nbsp;</code>]] → [[:cat:Typing-aid templates]]
* {{tl|cl}}{{0|e}} → {{cl|Typing-aid templates}}
* {{tl|cl}}{{0|e}} → {{cl|Typing-aid templates}}
* {{tl|lc}}{{0|e}} → {{lc|Typing-aid templates}}
* {{tl|lc}}{{0|e}} → {{lc|Typing-aid templates}}
Line 137: Line 137:


When parameter 3 is either X or x,  
When parameter 3 is either X or x,  
or when a namespace is encountered, a check for existence is performed.<br>
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.  
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 later the category is defined, the display occurs like standard as above.
Line 167: Line 167:




#  {{Tle|T=C|Not-existing-cat}} produces {{C|Not-existing-cat}}<br><!--
#  {{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|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}} 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|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|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|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|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}}
-->{{Tle|T=C|Not-existing-cat|displayname|X}} produces {{C|Not-existing-cat|displayname|X}}


Line 192: Line 192:


==== Interwiki access ====
==== 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.  
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||en}} or {{Tle|T=C|Main|p2=3|en}} produces {{C|Main||en}}
*{{Tle|T=C|Main||en}} or {{Tle|T=C|Main|p2=3|en}} produces {{C|Main||en}}

Revision as of 19:46, 31 October 2022

Template:TemplateBox/sandbox

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 }} 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 [[Category: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

{{Commons:Link templates/Category links}}

Cookies help us deliver our services. By using our services, you agree to our use of cookies.