Difference between revisions of "Template:Categorylink"

From Twinsuniverse
Jump to: navigation, search
m
Line 1: Line 1:
<includeonly></includeonly><noinclude>
+
<includeonly>{{
{{Stub}}This template '''will be''' used as a bridge between the [[Template:Categorizer]] and different type categorizers like [[Template:Infobox Character/gender]].
+
#if: {{{category|}}}
 +
|{{
 +
    #if: {{{article|}}}
 +
    |{{
 +
        #if: {{{label|}}}
 +
        | [[{{{article}}}|{{{label}}}]]
 +
        | [[{{{article}}}]] }}{{superlink|article=:Category:{{{category}}}|label={{{catlabel|list all}}}}}
 +
    |{{
 +
        #if: {{{label|}}}
 +
        |{{{label}}}{{superlink|article=:Category:{{{category}}}|label={{{catlabel|list all}}}}}
 +
        |[[:Category:{{{category}}}|{{{catlabel|}}}]] }} }}
 +
}}</includeonly><noinclude>
 +
This template will render a link to a category. If the category has a main article and it is specified, a link to the article will be rendered instead and the link to the category itself will turn into a <nowiki>{{</nowiki>[[Template:Superlink|Superlink]]<nowiki>}}</nowiki>.
  
==Development issues==
+
This template does not actually categorize an article under the specified category, for that, use the <nowiki>{{</nowiki>[[Template:Categorizer|Categorizer]]<nowiki>}}</nowiki> wrapper.
What kind of functionality should the category link offer? Should it make the [[Template:superlink|superlink]] optional?
+
At least it should offer a way to encapsulate the automatic categorization feature within the categorizer template.
+
  
The current [[Template:Categorizer]] does both the 'category link' and automatic categorization, but these two features should not be bound. Something else should be able to categorize as well, and sharing code would be desired.
+
==Parameters==
 +
* '''category''': The name of the category to link to (case sensitive, defaults to nothing displayed)
 +
* '''catlabel''': An optional text to display on the link to the category (case sensitive, defaults to '''category''' or to "list all" if '''article''' is specified)
 +
* '''article''': A main article for the category (case sensitive, pushes the link to the category into a superlink)
 +
* '''label''': An optional text to display on the link to the main article (case sensitice, defaults to '''article''')
 +
 
 +
 
 +
'''''Note''': The link to the category will be pushed into a superlink if either '''article''' or '''label''' or both are specified.''
 +
 
 +
'''''Note''': The '''label''' may be used to optionally display custom text on the '''article''' link, but may also be used instead to remove the link and render text only.''
 +
 
 +
'''''Note''': The '''catlabel''' may be used to optionally display custom text on the '''category''' link, but the latter is not optional, unlike '''article'''.''
 +
 
 +
==Syntax==
 +
<nowiki>{{categorylink
 +
|category=
 +
|label=
 +
|article=
 +
|label=
 +
}}</nowiki>
 +
 
 +
==Examples==
 +
Common use includes both the '''category''' and '''article''' parameters:
 +
<nowiki>{{categorylink|category=Quetches|article=Quetch}}</nowiki>
 +
 
 +
:[[Quetch]]{{superlink|article=:Category:Quetches|label=list all}}
 +
 
 +
 
 +
Both the text of the category link and article link may be customized, like this:
 +
<nowiki>{{categorylink
 +
|category=Quetches
 +
|catlabel=click here
 +
|article=Quetch
 +
|label=Resident
 +
}}</nowiki>
 +
 
 +
:[[Quetch|Resident]]{{superlink|article=:Category:Quetches|label=click here}}
 +
 
 +
 
 +
A different use includes only the '''category''' parameter, which would only render a link to the category itself like this:
 +
<nowiki>{{categorylink|category=Grobos}}</nowiki>
 +
 
 +
:[[:Category:Grobos|Grobos]]
 +
 
 +
 
 +
And again the text of the category link may be customized, like this:
 +
<nowiki>{{categorylink|category=Grobos|catlabel=Elephants}}</nowiki>
 +
 
 +
:[[:Category:Grobos|Elephants]]
 +
 
 +
 
 +
And even a third use includes the '''category''' parameter, combined not with the article but '''label''' parameter, which renders as the first example above but without a link on the article:
 +
<nowiki>{{categorylink|category=Quetches|label=Quetch}}</nowiki>
 +
<nowiki>{{categorylink|category=Quetches|label=Quetch|catlabel=members}}</nowiki>
 +
 
 +
:Quetch{{superlink|article=:Category:Quetches|label=list all}}
 +
:Quetch{{superlink|article=:Category:Quetches|label=members}}
 +
 
 +
 
 +
To summarize:
 +
* the '''catlabel''' parameter is used to display an optional text on the '''category''' link
 +
* the '''label''' parameter is used to display an optional text on the '''article''' link if it is specified, or instead if not
 +
* if an '''article''' is specified or a '''label''' replacement, the category link is pushed into a superlink behind it.
  
 
[[Category:System Templates]]
 
[[Category:System Templates]]
 
</noinclude>
 
</noinclude>

Revision as of 23:37, 5 December 2012

This template will render a link to a category. If the category has a main article and it is specified, a link to the article will be rendered instead and the link to the category itself will turn into a {{Superlink}}.

This template does not actually categorize an article under the specified category, for that, use the {{Categorizer}} wrapper.

Parameters

  • category: The name of the category to link to (case sensitive, defaults to nothing displayed)
  • catlabel: An optional text to display on the link to the category (case sensitive, defaults to category or to "list all" if article is specified)
  • article: A main article for the category (case sensitive, pushes the link to the category into a superlink)
  • label: An optional text to display on the link to the main article (case sensitice, defaults to article)


Note: The link to the category will be pushed into a superlink if either article or label or both are specified.

Note: The label may be used to optionally display custom text on the article link, but may also be used instead to remove the link and render text only.

Note: The catlabel may be used to optionally display custom text on the category link, but the latter is not optional, unlike article.

Syntax

{{categorylink
 |category=
 |label=
 |article=
 |label=
}}

Examples

Common use includes both the category and article parameters:

{{categorylink|category=Quetches|article=Quetch}}
Quetch [list all]


Both the text of the category link and article link may be customized, like this:

{{categorylink
 |category=Quetches
 |catlabel=click here
 |article=Quetch
 |label=Resident
}}
Resident [click here]


A different use includes only the category parameter, which would only render a link to the category itself like this:

{{categorylink|category=Grobos}}
Grobos


And again the text of the category link may be customized, like this:

{{categorylink|category=Grobos|catlabel=Elephants}}
Elephants


And even a third use includes the category parameter, combined not with the article but label parameter, which renders as the first example above but without a link on the article:

{{categorylink|category=Quetches|label=Quetch}}
{{categorylink|category=Quetches|label=Quetch|catlabel=members}}
Quetch [list all]
Quetch [members]


To summarize:

  • the catlabel parameter is used to display an optional text on the category link
  • the label parameter is used to display an optional text on the article link if it is specified, or instead if not
  • if an article is specified or a label replacement, the category link is pushed into a superlink behind it.