Template:Sortkey: Difference between revisions

Template page
w:c:strategywiki>Najzere
(sortkey template)
 
w:c:strategywiki>Najzere
m (repurpose, category sort)
Line 1: Line 1:
<span style="display:none;">{{{1|{{#if:{{{time|}}}|{{#time:Ymd|{{{time}}}}}|!}}}}}</span>{{#if:{{{2|}}}|{{{2}}}}}<noinclude>
<span style="display:none;">{{#time:Ymd|{{{1}}}}}</span>{{{1}}}<noinclude>
 
{{documentation}}
{{documentation}}
[[Category:Templates]]</noinclude>
[[Category:Templates|{{PAGENAME}}]]</noinclude>

Revision as of 04:02, 2 June 2011

Error: Invalid time.{{{1}}}

This page has been transcluded from Template:Sortkey/Documentation.


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 Error: Invalid time.{{{1}}}The beginning of time
{{sortkey|5-3-2008}} 200803055-3-2008
{{sortkey|03-Jan-2007}} 2007010303-Jan-2007
{{sortkey||20110222}}My birthday 20241122My birthday