Template:Sort/Documentation: Difference between revisions

Template page
(col)
 
w:c:strategywiki>Notmyhandle
(copied from /docs, cleanup)
Line 1: Line 1:
#REDIRECT [[Template:Sort/doc]]
This template is for optionally sorting tables by specified sortkeys.
 
;Usage:<code><nowiki>{{</nowiki>sort|''sort value''|''displayed value''}}</code>
 
If necessary, one can apply sorting using a sortkey that [[wp:Help:Cascading_style_sheets#Non-display|due to CSS is not displayed]]: <nowiki><span style="display:none">...</span></nowiki>. Javascript sorting is based on the text inside and outside the tags, without the tags themselves. A hidden sortkey can be put at the start.
 
This template makes that more convenient. The first parameter is the sortkey; the second parameter is the wikitext of what has to be displayed. By default, this is the sortkey with link brackets.
 
=====Example=====
<pre>
|{{sort|Brothers Karamazov|[[The Brothers Karamazov]]}}
</pre>
 
It presently works through hidden CSS, as described at [[wp:Help:Sorting]]. If a cleaner way of doing this is developed, the template will be changed. A table using this template should use it in all rows.
 
'''Note:''' You should always have the same number of columns for a given table. E.g., if the wikitable will be sorting the numbers 56 (foo), 94 (bar), and 103 (baz), then your templates within that wikitable should be
 
<pre>{{sort|056|foo}}
{{sort|094|bar}}
{{sort|103|baz}}</pre>
 
<noinclude>[[Category:Template documentation|N]]</noinclude>

Revision as of 17:42, 22 August 2012

This template is for optionally sorting tables by specified sortkeys.

Usage
{{sort|sort value|displayed value}}

If necessary, one can apply sorting using a sortkey that due to CSS is not displayed: <span style="display:none">...</span>. Javascript sorting is based on the text inside and outside the tags, without the tags themselves. A hidden sortkey can be put at the start.

This template makes that more convenient. The first parameter is the sortkey; the second parameter is the wikitext of what has to be displayed. By default, this is the sortkey with link brackets.

Example
|{{sort|Brothers Karamazov|[[The Brothers Karamazov]]}}

It presently works through hidden CSS, as described at wp:Help:Sorting. If a cleaner way of doing this is developed, the template will be changed. A table using this template should use it in all rows.

Note: You should always have the same number of columns for a given table. E.g., if the wikitable will be sorting the numbers 56 (foo), 94 (bar), and 103 (baz), then your templates within that wikitable should be

{{sort|056|foo}}
{{sort|094|bar}}
{{sort|103|baz}}