Template:NameSorter: Difference between revisions

From ChoralWiki
Jump to navigation Jump to search
(added function StripAccents)
(added documentation)
Line 1: Line 1:
{{#ifexpr: {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} = {{#len:{{{1|{{PAGENAME}}}}}}}
<includeonly>{{#ifexpr: {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} = {{#len:{{{1|{{PAGENAME}}}}}}}
|{{StripAccents|{{{1|{{PAGENAME}}}}} }}
|{{StripAccents|{{{1|{{PAGENAME}}}}} }}
|{{StripAccents|{{#explode:{{{1|{{PAGENAME}}}}}||-1}}, {{#sub:{{{1|{{PAGENAME}}}}}||{{#expr:{{#len:{{{1|{{PAGENAME}}}}}}} - {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} }} }} }}
|{{StripAccents|{{#explode:{{{1|{{PAGENAME}}}}}||-1}}, {{#sub:{{{1|{{PAGENAME}}}}}||{{#expr:{{#len:{{{1|{{PAGENAME}}}}}}} - {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} }} }} }}
}}<noinclude>
}}</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.


'''Syntax:'''
* <tt><nowiki>{{LastName}}</nowiki></tt> returns the contents of <tt><nowiki>{{PAGENAME}}</nowiki></tt> after processing it.
'''Syntax with an optional parameter:'''
* <tt><nowiki>{{LastName|Antonín Dvořák}}</nowiki></tt> returns "{{LastName|Antonín Dvořák}}"
This template is meant to be used in conjunction with the magic word <tt><nowiki>DEFAULTSORT</nowiki></tt> in Composer and User pages, delivering to it an appropriate sort key.
'''Example:'''
* <tt><nowiki>{{DEFAULTSORT:{{LastName}}}}</nowiki></tt>
}}
[[Category:Templates|{{PAGENAME}}]]
[[Category:Templates|{{PAGENAME}}]]
</noinclude>
</noinclude>

Revision as of 05:12, 16 May 2009

Converts a text in the form "Name(s) Surname" to the form "Surname, Name(s)", removing all diacritics in the process.

Syntax:

  • {{LastName}} returns the contents of {{PAGENAME}} after processing it.

Syntax with an optional parameter:


This template is meant to be used in conjunction with the magic word DEFAULTSORT in Composer and User pages, delivering to it an appropriate sort key.

Example:

  • {{DEFAULTSORT:{{LastName}}}}