Template:Sortkey/Documentation: Difference between revisions

Template page
w:c:strategywiki>Najzere
(doc page)
 
w:c:strategywiki>Najzere
m (no parameter usage)
Line 9: Line 9:
You can also use this template to create your own sortkey, not based on time, by using the second unnamed parameter by itself. This can be useful for getting text to sort how you want (such as sorting "The Goonies" by the letter "G"). Note that when using the second unnamed parameter, nothing is returned after the sortkey.
You can also use this template to create your own sortkey, not based on time, by using the second unnamed parameter by itself. This can be useful for getting text to sort how you want (such as sorting "The Goonies" by the letter "G"). Note that when using the second unnamed parameter, nothing is returned after the sortkey.
:<code><nowiki>{{sortkey||Goonies, The}}</nowiki></code> will return ''<nowiki><span style="display:none;">Goonies, The</span></nowiki>''.
:<code><nowiki>{{sortkey||Goonies, The}}</nowiki></code> will return ''<nowiki><span style="display:none;">Goonies, The</span></nowiki>''.
;No parameters
If no parameters are used, the template returns an exclamation point, which will sort before most other characters.
:<code><nowiki>{{sortkey}}</nowiki></code> will return ''<nowiki><span style="display:none;">!</span></nowiki>''.


==Example==
==Example==
Line 18: Line 22:
|-
|-
| <code><nowiki>{{sortkey|October 3, 2005}}</nowiki></code> || {{sortkey|October 3, 2005}}
| <code><nowiki>{{sortkey|October 3, 2005}}</nowiki></code> || {{sortkey|October 3, 2005}}
|-
| <code><nowiki>{{sortkey}}</nowiki>The beginning of time</code> || {{sortkey}}The beginning of time
|-
|-
| <code><nowiki>{{sortkey|5-3-2008}}</nowiki></code> || {{sortkey|5-3-2008}}
| <code><nowiki>{{sortkey|5-3-2008}}</nowiki></code> || {{sortkey|5-3-2008}}

Revision as of 04:22, 2 June 2011

This template returns a hidden string that can be used to enforce a specific sort order in sortable tables.

Usage

First unnamed parameter

The most useful feature of the template is creating chronological sortkeys by using a date. Most date formats will be recognized, such as "January 1, 2011" or "2011-Jan-01". For instance:

{{sortkey|January 1, 2011}} will return <span style="display:none;">20110101</span>January 1, 2011.
Second unnamed parameter

You can also use this template to create your own sortkey, not based on time, by using the second unnamed parameter by itself. This can be useful for getting text to sort how you want (such as sorting "The Goonies" by the letter "G"). Note that when using the second unnamed parameter, nothing is returned after the sortkey.

{{sortkey||Goonies, The}} will return <span style="display:none;">Goonies, The</span>.
No parameters

If no parameters are used, the template returns an exclamation point, which will sort before most other characters.

{{sortkey}} will return <span style="display:none;">!</span>.

Example

Code Result
{{sortkey|Dec-2011}} 20111201Dec-2011
{{sortkey|October 3, 2005}} 20051003October 3, 2005
{{sortkey}}The beginning of time !The beginning of time
{{sortkey|5-3-2008}} 200803055-3-2008
{{sortkey|03-Jan-2007}} 2007010303-Jan-2007
{{sortkey||20110222}}My birthday 20110222My birthday