Template:DEFAULTSORT/doc

From WikiAlpha
Jump to: navigation, search
The below content is licensed according to Creative Commons Attribution-ShareAlike License contrary to the public domain logo at the foot of the page. It originally appeared on http://en.wikipedia.org. The original article might still be accessible here. You may be able to find a list of the article's previous contributors on the talk page.
Template:Important

{{DEFAULTSORT:<sort key>}} is a magic word used to modify the sequence of pages shown on category pages. The given sort key in a specific page is used to determine that page's position in all category pages where the page is listed. Note: The specific page will still be listed with its original title, regardless of the modified sort order. The sort key can be overridden for specific categories, if their Template:Brackets tags contain a differing individual sort key.

It is not necessary to use DEFAULTSORT at all if the article or page should be alphabetized according to its title (true for most articles).

For background information on how the pages in a category are ordered, see Template:Section link.

Understanding DEFAULTSORT

By default, pages listed on a category page are sorted by {{PAGENAME}}. It is possible to set a different sort key by using the {{DEFAULTSORT}} magic word.

In the case of multiple default sort key tags, the last DEFAULTSORT on the final rendering of a page applies for all categories, regardless of the position of the category tags. This also means that a DEFAULTSORT tag included from a template is not effective if another DEFAULTSORT tag occurs later on the page, even if the later DEFAULTSORT tag is also "hidden" (included by another template).

Placement

When using {{DEFAULTSORT}} to modify the default sort key, the magic word should be placed at the left margin of a new line, immediately above the line which begins the list of categories. For example, the last lines of a typical article titled Forename Surname could look like:

==Final section==
Final line of content in "final section".

{{Templates}}

{{Last metadata template
| LAST PARAMETER OF LAST METADATA TEMPLATE = Parameter content
}}
{{DEFAULTSORT:Surname, Forename}}
[[Category:Forename Surname| ]]

Tracking category

See also

TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools.

See the monthly error report for this template.

TemplateData for DEFAULTSORT

<templatedata> { "description": "Warning: Default sort key "<sort key>" overrides earlier default sort key "DEFAULTSORT/doc". is a magic word used to modify the sequence of pages shown on category pages. Please use Warning: Default sort key "Sortkey" overrides earlier default sort key "<sort key>". rather than, with a colon (\":\"), not a pipe symbol (\"|\"). This uses the magic word directly instead of using the template to call the magic word.", "params": { "1": {} } } </templatedata>