Template:NameSorter: Difference between revisions

From ChoralWiki
Jump to navigation Jump to search
m (moved Template:LastName to Template:NameSorter: following a suggestion by Chuck to avoid confusion with the "last name" itself)
(updated doc)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#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}}}} }} }} }}
}}</includeonly><noinclude><!--
-->{{DisplayBox|bgcolor=g|text=
Converts a text in the form "Name(s) Surname" to the form "Surname, Name(s)", removing all diacritics in the process.
Converts a text in the form "Name(s) Surname" to the form "Surname, Name(s)", removing all diacritics in the process.


'''Syntax:'''
'''Syntax:'''
* <tt><nowiki>{{LastName}}</nowiki></tt> returns the contents of <tt><nowiki>{{PAGENAME}}</nowiki></tt> after processing it.
* {{tl|NameSorter}} returns the contents of <tt><nowiki>{{PAGENAME}}</nowiki></tt> after processing it.


'''Syntax with an optional parameter:'''
'''Syntax with an optional parameter:'''
* <tt><nowiki>{{LastName|Antonín Dvořák}}</nowiki></tt> returns "{{LastName|Antonín Dvořák}}"
* {{tl|NameSorter|Antonín Dvořák}} returns "{{NameSorter|Antonín Dvořák}}"




This template is meant to be used in conjunction with the magic word <tt><nowiki>DEFAULTSORT</nowiki></tt> inside Composer and User pages, delivering to it an appropriate sort key.
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:{{LastName}}}}</nowiki></tt>
* <tt><nowiki>{{DEFAULTSORT:{{NameSorter}}}}</nowiki></tt>


In the cases in which the template returns an invalid sort key, as for example "Rue, Pierre de la", use a textual key instead:
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>
* <tt><nowiki>{{DEFAULTSORT:La Rue, Pierre de}}</nowiki></tt>
===See also===
*[[Template:LastNameFirst]]
*[[Template:StripAccents]]
}}
}}
[[Category:Templates|{{PAGENAME}}]]
[[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