Difference between revisions of "Template:NameSorter"

From ChoralWiki
Jump to navigation Jump to search
(added function StripAccents)
(updated doc)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{#ifexpr: {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} = {{#len:{{{1|{{PAGENAME}}}}}}}
+
<includeonly>{{StripAccents|{{LastNameFirst|{{{1|{{PAGENAME}} }}} }} }}</includeonly><noinclude><!--
|{{StripAccents|{{{1|{{PAGENAME}}}}} }}
+
-->{{DisplayBox|title=Documentation|text=
|{{StripAccents|{{#explode:{{{1|{{PAGENAME}}}}}||-1}}, {{#sub:{{{1|{{PAGENAME}}}}}||{{#expr:{{#len:{{{1|{{PAGENAME}}}}}}} - {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} }} }} }}
+
Converts a text in the form "Name(s) Surname" to the form "Surname, Name(s)", removing all diacritics in the process.
}}<noinclude>
 
  
[[Category:Templates|{{PAGENAME}}]]
+
'''Syntax:'''
 +
* {{tl|NameSorter}} returns the contents of <tt><nowiki>{{PAGENAME}}</nowiki></tt> after processing it.
 +
 
 +
'''Syntax with an optional parameter:'''
 +
* {{tl|NameSorter|Antonín Dvořák}} returns "{{NameSorter|Antonín Dvořák}}"
 +
 
 +
 
 +
This template is meant to be used as a parameter for the magic word <tt><nowiki>DEFAULTSORT</nowiki></tt> inside Composer and Editor pages, producing an appropriate sort key.
 +
 
 +
* <tt><nowiki>{{DEFAULTSORT:{{NameSorter}}}}</nowiki></tt>
 +
 
 +
In the situations where the normal usage of this template would render an incorrect sort key (as for example "Rue, Pierre de la"), use a textual key instead:
 +
 
 +
* <tt><nowiki>{{DEFAULTSORT:La Rue, Pierre de}}</nowiki></tt>
 +
 
 +
===See also===
 +
*[[Template:LastNameFirst]]
 +
*[[Template:StripAccents]]
 +
}}
 +
[[Category:Text formatting templates]]
 
</noinclude>
 
</noinclude>

Latest revision as of 12:58, 20 May 2013

Documentation

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 as a parameter for the magic word DEFAULTSORT inside Composer and Editor pages, producing an appropriate sort key.

  • {{DEFAULTSORT:{{NameSorter}}}}

In the situations where the normal usage of this template would render an incorrect sort key (as for example "Rue, Pierre de la"), use a textual key instead:

  • {{DEFAULTSORT:La Rue, Pierre de}}

See also