Template:NameSorter: Difference between revisions
Jump to navigation
Jump to search
m (fix name) |
(ucfirst: to guarantee that the first letter is uppercase) |
||
Line 1: | Line 1: | ||
<includeonly>{{#ifexpr: {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} = {{#len:{{{1|{{PAGENAME}}}}}}} | <includeonly>{{#ifexpr: {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} = {{#len:{{{1|{{PAGENAME}}}}}}} | ||
|{{StripAccents|{{{1|{{PAGENAME}}}}} }} | |{{ucfirst:{{StripAccents|{{{1|{{PAGENAME}}}}} }} }} | ||
|{{StripAccents|{{#explode:{{{1|{{PAGENAME}}}}}||-1}}, {{#sub:{{{1|{{PAGENAME}}}}}||{{#expr:{{#len:{{{1|{{PAGENAME}}}}}}} - {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} }} }} }} | |{{ucfirst:{{StripAccents|{{#explode:{{{1|{{PAGENAME}}}}}||-1}}, {{#sub:{{{1|{{PAGENAME}}}}}||{{#expr:{{#len:{{{1|{{PAGENAME}}}}}}} - {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} }} }} }} }} | ||
}}</includeonly><noinclude><!-- | }}</includeonly><noinclude><!-- | ||
-->{{DisplayBox|bgcolor=g|text= | -->{{DisplayBox|bgcolor=g|text= |
Revision as of 03:53, 18 September 2009
Converts a text in the form "Name(s) Surname" to the form "Surname, Name(s)", removing all diacritics in the process.
Syntax:
- {{NameSorter}} returns the contents of {{PAGENAME}} after processing it.
Syntax with an optional parameter:
- {{NameSorter|Antonín Dvořák}} returns "Dvorak, Antonin"
This template is meant to be used in conjunction with the magic word DEFAULTSORT inside Composer and User pages, delivering to it an appropriate sort key.
- {{DEFAULTSORT:{{NameSorter}}}}
In the cases in which the template returns an invalid sort key, as for example "Rue, Pierre de la", use a textual key instead:
- {{DEFAULTSORT:La Rue, Pierre de}}