I want to use the MODx countrylist files to populate a html select for signup/edit profile. This works fine however I cannot think of a way to have this appear in alphabetically sorted order.
MODx comes with countrylists in manager/includes/lang/country.
In the English version these are, more or less, sorted. In other language they are not.
an excerpt of the german one looks like this
$_country_lang["49"] = 'Kongo, Republik von'; // Congo
$_country_lang["52"] = 'Cote D&39;Ivoire'; // Cote D&39;Ivoire
$_country_lang["53"] = 'Kroatien'; // Croatia
$_country_lang["54"] = 'Kuba'; // Cuba
$_country_lang["55"] = 'Zypern'; // Cyprus
$_country_lang["56"] = 'Tschechische Republik'; // Czech Republic
The same excerpt looks like this in english
$_country_lang["49"] = 'Congo, Republic of the'; // Congo
$_country_lang["52"] = 'Cote D'Ivoire'; // Cote D'Ivoire
$_country_lang["53"] = 'Croatia'; // Croatia
$_country_lang["54"] = 'Cuba'; // Cuba
$_country_lang["55"] = 'Cyprus'; // Cyprus
$_country_lang["56"] = 'Czech Republic'; // Czech Republic
This is kind of hard to fix. Fetching countrylists from an sql statement would easily make your select dropdown options alphabetically sorted. But in MODx Evo I only have them in plain arrays.
Only solutions I can think of is:
- heavy preprocessing of the array in php
- making it a table (very laborious)
- sort it in javascript as a last resort
Anyone here has another idea or knows a way to make the second alternative viable in a reasonable amount of time?