Managing long lists with Listo

Managing long lists with Listo

Imagine that you need to make a contact form that has fields for the sender’s location and you want them to choose their country from a list. There are about 200 countries in the world — you’ll soon realize that the list becomes terribly long.

Previously, the only way to generate such a long list with Contact Form 7 was to manually add all the options into a form-tag as shown below.

[select your-country “Aruba” “Afghanistan” “Angola” “Albania” “Andorra” “United Arab Emirates” “Argentina” “Armenia” “American Samoa” “Antigua and Barbuda” “Australia” “Austria” “Azerbaijan” “Burundi” “Belgium” “Benin” “Burkina Faso” “Bangladesh” “Bulgaria” “Bahrain” “Bahamas” “Bosnia and Herzegovina” “Belarus” “Belize” “Bermuda” “Bolivia, Plurinational State of” “Brazil” “Barbados” “Brunei Darussalam” “Bhutan” “Botswana” “Central African Republic” “Canada” “Switzerland” “Chile” “China” “Côte d’Ivoire” “Cameroon” “Congo, the Democratic Republic of the” “Congo” “Cook Islands” “Colombia” “Comoros” “Cape Verde” “Costa Rica” “Cuba” “Cayman Islands” “Cyprus” “Czech Republic” “Germany” “Djibouti” “Dominica” “Denmark” “Dominican Republic” “Algeria” “Ecuador” “Egypt” “Eritrea” “Spain” “Estonia” “Ethiopia” “Finland” “Fiji” “France” “Micronesia, Federated States of” “Gabon” “United Kingdom” “Georgia” “Ghana” “Guinea” “Gambia” “Guinea-Bissau” “Equatorial Guinea” “Greece” “Grenada” “Guatemala” “Guam” “Guyana” “Hong Kong” “Honduras” “Croatia” “Haiti” “Hungary” “Indonesia” “India” “Ireland” “Iran, Islamic Republic of” “Iraq” “Iceland” “Israel” “Italy” “Jamaica” “Jordan” “Japan” “Kazakhstan” “Kenya” “Kyrgyzstan” “Cambodia” “Kiribati” “Saint Kitts and Nevis” “Korea, Republic of” “Kuwait” “Lao People’s Democratic Republic” “Lebanon” “Liberia” “Libya” “Saint Lucia” “Liechtenstein” “Sri Lanka” “Lesotho” “Lithuania” “Luxembourg” “Latvia” “Morocco” “Monaco” “Moldova, Republic of” “Madagascar” “Maldives” “Mexico” “Marshall Islands” “Macedonia, the former Yugoslav Republic of” “Mali” “Malta” “Myanmar” “Montenegro” “Mongolia” “Mozambique” “Mauritania” “Mauritius” “Malawi” “Malaysia” “Namibia” “Niger” “Nigeria” “Nicaragua” “Netherlands” “Norway” “Nepal” “Nauru” “New Zealand” “Oman” “Pakistan” “Panama” “Peru” “Philippines” “Palau” “Papua New Guinea” “Poland” “Puerto Rico” “Korea, Democratic People’s Republic of” “Portugal” “Paraguay” “Palestine, State of” “Qatar” “Romania” “Russian Federation” “Rwanda” “Saudi Arabia” “Sudan” “Senegal” “Singapore” “Solomon Islands” “Sierra Leone” “El Salvador” “San Marino” “Somalia” “Serbia” “Sao Tome and Principe” “Suriname” “Slovakia” “Slovenia” “Sweden” “Swaziland” “Seychelles” “Syrian Arab Republic” “Chad” “Togo” “Thailand” “Tajikistan” “Turkmenistan” “Timor-Leste” “Tonga” “Trinidad and Tobago” “Tunisia” “Turkey” “Tuvalu” “Taiwan, Province of China” “Tanzania, United Republic of” “Uganda” “Ukraine” “Uruguay” “United States” “Uzbekistan” “Saint Vincent and the Grenadines” “Venezuela, Bolivarian Republic of” “Virgin Islands, U.S.” “Viet Nam” “Vanuatu” “Samoa” “Yemen” “South Africa” “Zambia” “Zimbabwe”]

Managing 200 or more options is almost impossible, and parsing this form-tag would consume memory and time on your server computer. The situation of a list of countries in a contact form is not that rare; it should be easier to set up. That’s why I created Listo, another WordPress plugin.

Listo is a simple plugin that provides several kinds of common lists for other plugins like Contact Form 7. Listo currently provides lists of world countries, U.S. subdivisions, and world currencies (shown at the bottom of this page), with more to come.

Contact Form 7 supports cooperation with Listo and allows drop-down menus, checkboxes, and radio buttons, with a long list of options that Listo provides. You don’t need painful manual editing anymore.

How to manage long lists in a contact form

Let’s try creating a drop-down menu for selecting a country. We get the option values from Listo, so activate Listo if it’s not active yet.

Let’s start by creating a form-tag for a typical drop-down menu. We use [select] form-tag.

[select your-country]

This tag doesn’t have values yet, so it will be displayed as an empty menu. Next, we add the countries list as its option values. To add values provided by Listo, add a ‘data’ option to a form-tag, like this.

[select your-country data:countries]

Just adding data:countries gives the menu about 200 country options. Simple, right?

Looking through the menu items, you may find something unexpected; for example, “Antarctica” is in the countries list. Is Antarctica a country where people live? The reason Antarctica is in the list is that the data source of the countries list is the ISO 3166 standard, which includes some non-country special areas.

Thus, the definition of a country can differ according to standards. For dealing with different definitions, Listo also provides a grouping function. For the world countries list, Listo provides two subgroups: “un” and “olympic”. The “un” subgroup only includes members of the United Nations, while the “olympic” subgroup only includes participating nations at the 2012 London Summer Olympic Games. A complete list with subgroups is shown at the bottom of this page.

To specify the data option with subgroup, append a period (.) and the name of subgroup to the option.

[select your-country data:countries.olympic]

This menu will only include participating Olympic nations in its options; you won’t see Antarctica there.

The complete lists Listo provides

Countries [countries]

A list of countries and dependent territories based on the ISO 3166 standard.

Usage example:

[select your-country data:countries.olympic]

NameIn Group1Arubaolympic2Afghanistanun, olympic3Angolaun, olympic4Anguilla5Åland Islands6Albaniaun, olympic7Andorraun, olympic8United Arab Emiratesun, olympic9Argentinaun, olympic10Armeniaun, olympic11American Samoaolympic12Antarctica13French Southern Territories14Antigua and Barbudaun, olympic15Australiaun, olympic16Austriaun, olympic17Azerbaijanun, olympic18Burundiun, olympic19Belgiumun, olympic20Beninun, olympic21Bonaire, Sint Eustatius and Saba22Burkina Fasoun, olympic23Bangladeshun, olympic24Bulgariaun, olympic25Bahrainun, olympic26Bahamasun, olympic27Bosnia and Herzegovinaun, olympic28Saint Barthélemy29Belarusun, olympic30Belizeun, olympic31Bermudaolympic32Bolivia, Plurinational State ofun, olympic33Brazilun, olympic34Barbadosun, olympic35Brunei Darussalamun, olympic36Bhutanun, olympic37Bouvet Island38Botswanaun, olympic39Central African Republicun, olympic40Canadaun, olympic41Cocos (Keeling) Islands42Switzerlandun, olympic43Chileun, olympic44Chinaun, olympic45Côte d’Ivoireun, olympic46Cameroonun, olympic47Congo, the Democratic Republic of theun, olympic48Congoun, olympic49Cook Islandsolympic50Colombiaun, olympic51Comorosun, olympic52Cape Verdeun, olympic53Costa Ricaun, olympic54Cubaun, olympic55Curaçao56Christmas Island57Cayman Islandsolympic58Cyprusun, olympic59Czech Republicun, olympic60Germanyun, olympic61Djiboutiun, olympic62Dominicaun, olympic63Denmarkun, olympic64Dominican Republicun, olympic65Algeriaun, olympic66Ecuadorun, olympic67Egyptun, olympic68Eritreaun, olympic69Western Sahara70Spainun, olympic71Estoniaun, olympic72Ethiopiaun, olympic73Finlandun, olympic74Fijiun, olympic75Falkland Islands (Malvinas)76Franceun, olympic77Faroe Islands78Micronesia, Federated States ofun, olympic79Gabonun, olympic80United Kingdomun, olympic81Georgiaun, olympic82Guernsey83Ghanaun, olympic84Gibraltar85Guineaun, olympic86Guadeloupe87Gambiaun, olympic88Guinea-Bissauun, olympic89Equatorial Guineaun, olympic90Greeceun, olympic91Grenadaun, olympic92Greenland93Guatemalaun, olympic94French Guiana95Guamolympic96Guyanaun, olympic97Hong Kongolympic98Heard Island and McDonald Islands99Hondurasun, olympic100Croatiaun, olympic101Haitiun, olympic102Hungaryun, olympic103Indonesiaun, olympic104Isle of Man105Indiaun, olympic106British Indian Ocean Territory107Irelandun, olympic108Iran, Islamic Republic ofun, olympic109Iraqun, olympic110Icelandun, olympic111Israelun, olympic112Italyun, olympic113Jamaicaun, olympic114Jersey115Jordanun, olympic116Japanun, olympic117Kazakhstanun, olympic118Kenyaun, olympic119Kyrgyzstanun, olympic120Cambodiaun, olympic121Kiribatiun, olympic122Saint Kitts and Nevisun, olympic123Korea, Republic ofun, olympic124Kuwaitun, olympic125Lao People’s Democratic Republicun, olympic126Lebanonun, olympic127Liberiaun, olympic128Libyaun, olympic129Saint Luciaun, olympic130Liechtensteinun, olympic131Sri Lankaun, olympic132Lesothoun, olympic133Lithuaniaun, olympic134Luxembourgun, olympic135Latviaun, olympic136Macao137Saint Martin (French part)138Moroccoun, olympic139Monacoun, olympic140Moldova, Republic ofun, olympic141Madagascarun, olympic142Maldivesun, olympic143Mexicoun, olympic144Marshall Islandsun, olympic145Macedonia, the former Yugoslav Republic ofun, olympic146Maliun, olympic147Maltaun, olympic148Myanmarun, olympic149Montenegroun, olympic150Mongoliaun, olympic151Northern Mariana Islands152Mozambiqueun, olympic153Mauritaniaun, olympic154Montserrat155Martinique156Mauritiusun, olympic157Malawiun, olympic158Malaysiaun, olympic159Mayotte160Namibiaun, olympic161New Caledonia162Nigerun, olympic163Norfolk Island164Nigeriaun, olympic165Nicaraguaun, olympic166Niue167Netherlandsun, olympic168Norwayun, olympic169Nepalun, olympic170Nauruun, olympic171New Zealandun, olympic172Omanun, olympic173Pakistanun, olympic174Panamaun, olympic175Pitcairn176Peruun, olympic177Philippinesun, olympic178Palauun, olympic179Papua New Guineaun, olympic180Polandun, olympic181Puerto Ricoolympic182Korea, Democratic People’s Republic ofun, olympic183Portugalun, olympic184Paraguayun, olympic185Palestine, State ofolympic186French Polynesia187Qatarun, olympic188Réunion189Romaniaun, olympic190Russian Federationun, olympic191Rwandaun, olympic192Saudi Arabiaun, olympic193Sudanun, olympic194Senegalun, olympic195Singaporeun, olympic196South Georgia and the South Sandwich Islands197Saint Helena, Ascension and Tristan da Cunha198Svalbard and Jan Mayen199Solomon Islandsun, olympic200Sierra Leoneun, olympic201El Salvadorun, olympic202San Marinoun, olympic203Somaliaun, olympic204Saint Pierre and Miquelon205Serbiaun, olympic206South Sudanun, olympic207Sao Tome and Principeun, olympic208Surinameun, olympic209Slovakiaun, olympic210Sloveniaun, olympic211Swedenun, olympic212Swazilandun, olympic213Sint Maarten (Dutch part)214Seychellesun, olympic215Syrian Arab Republicun, olympic216Turks and Caicos Islands217Chadun, olympic218Togoun, olympic219Thailandun, olympic220Tajikistanun, olympic221Tokelau222Turkmenistanun, olympic223Timor-Lesteun, olympic224Tongaun, olympic225Trinidad and Tobagoun, olympic226Tunisiaun, olympic227Turkeyun, olympic228Tuvaluun, olympic229Taiwan, Province of Chinaolympic230Tanzania, United Republic ofun, olympic231Ugandaun, olympic232Ukraineun, olympic233United States Minor Outlying Islands234Uruguayun, olympic235United Statesun, olympic236Uzbekistanun, olympic237Holy See (Vatican City State)238Saint Vincent and the Grenadinesun, olympic239Venezuela, Bolivarian Republic ofun, olympic240Virgin Islands, Britisholympic241Virgin Islands, U.S.olympic242Viet Namun, olympic243Vanuatuun, olympic244Wallis and Futuna245Samoaun, olympic246Yemenun, olympic247South Africaun, olympic248Zambiaun, olympic249Zimbabweun, olympic

U.S. subdivisions [us_subdivisions]

The list of subdivisions of the United States based on the ISO 3166-2:US standard.

Usage example:

[select your-state data:us_subdivisions.states data:us_subdivisions.districts]

NameIn Group1Alaskastates2Alabamastates3Arkansasstates4American Samoaoutlying_areas5Arizonastates6Californiastates7Coloradostates8Connecticutstates9District of Columbiadistricts10Delawarestates11Floridastates12Georgiastates13Guamoutlying_areas14Hawaiistates15Iowastates16Idahostates17Illinoisstates18Indianastates19Kansasstates20Kentuckystates21Louisianastates22Massachusettsstates23Marylandstates24Mainestates25Michiganstates26Minnesotastates27Missouristates28Northern Mariana Islandsoutlying_areas29Mississippistates30Montanastates31North Carolinastates32North Dakotastates33Nebraskastates34New Hampshirestates35New Jerseystates36New Mexicostates37Nevadastates38New Yorkstates39Ohiostates40Oklahomastates41Oregonstates42Pennsylvaniastates43Puerto Ricooutlying_areas44Rhode Islandstates45South Carolinastates46South Dakotastates47Tennesseestates48Texasstates49United States Minor Outlying Islandsoutlying_areas50Utahstates51Virginiastates52Virgin Islands, U.S.outlying_areas53Vermontstates54Washingtonstates55Wisconsinstates56West Virginiastates57Wyomingstates

Currencies [currencies]

A list of currencies based on the ISO 4217 standard.

Usage example:

[select your-currency data:currencies]

NameIn Group1United Arab Emirates dirham2Afghan afghani3Albanian lek4Armenian dram5Netherlands Antillean guilder6Angolan kwanza7Argentine peso8Australian dollar9Aruban florin10Azerbaijani manat11Bosnia and Herzegovina convertible mark12Barbados dollar13Bangladeshi taka14Bulgarian lev15Bahraini dinar16Burundian franc17Bermudian dollar18Brunei dollar19Boliviano20Brazilian real21Bahamian dollar22Bhutanese ngultrum23Botswana pula24Belarusian ruble25Belize dollar26Canadian dollar27Congolese franc28Swiss franc29Chilean peso30Chinese yuan31Colombian peso32Costa Rican colon33Cuban peso34Cape Verde escudo35Czech koruna36Djiboutian franc37Danish krone38Dominican peso39Algerian dinar40Egyptian pound41Eritrean nakfa42Ethiopian birr43Euro44Fiji dollar45Falkland Islands pound46Pound sterling47Georgian lari48Ghanaian cedi49Gibraltar pound50Gambian dalasi51Guinean franc52Guatemalan quetzal53Guyanese dollar54Hong Kong dollar55Honduran lempira56Croatian kuna57Haitian gourde58Hungarian forint59Indonesian rupiah60Israeli new shekel61Indian rupee62Iraqi dinar63Iranian rial64Icelandic króna65Jamaican dollar66Jordanian dinar67Japanese yen68Kenyan shilling69Kyrgyzstani som70Cambodian riel71Comoro franc72North Korean won73South Korean won74Kuwaiti dinar75Cayman Islands dollar76Kazakhstani tenge77Lao kip78Lebanese pound79Sri Lankan rupee80Liberian dollar81Lesotho loti82Lithuanian litas83Libyan dinar84Moroccan dirham85Moldovan leu86Malagasy ariary87Macedonian denar88Myanma kyat89Mongolian tugrik90Macanese pataca91Mauritanian ouguiya92Mauritian rupee93Maldivian rufiyaa94Malawian kwacha95Mexican peso96Malaysian ringgit97Mozambican metical98Namibian dollar99Nigerian naira100Nicaraguan córdoba101Norwegian krone102Nepalese rupee103New Zealand dollar104Omani rial105Panamanian balboa106Peruvian nuevo sol107Papua New Guinean kina108Philippine peso109Pakistani rupee110Polish złoty111Paraguayan guaraní112Qatari riyal113Romanian new leu114Serbian dinar115Russian ruble116Rwandan franc117Saudi riyal118Solomon Islands dollar119Seychelles rupee120Sudanese pound121Swedish krona/kronor122Singapore dollar123Saint Helena pound124Sierra Leonean leone125Somali shilling126Surinamese dollar127South Sudanese pound128São Tomé and Príncipe dobra129Syrian pound130Swazi lilangeni131Thai baht132Tajikistani somoni133Turkmenistani manat134Tunisian dinar135Tongan paʻanga136Turkish lira137Trinidad and Tobago dollar138New Taiwan dollar139Tanzanian shilling140Ukrainian hryvnia141Ugandan shilling142United States dollar143Uruguayan peso144Uzbekistan som145Venezuelan bolívar146Vietnamese dong147Vanuatu vatu148Samoan tala149CFA franc BEAC150East Caribbean dollar151CFA franc BCEAO152CFP franc (franc Pacifique)153Yemeni rial154South African rand155Zambian kwacha156Zimbabwe dollar
Share this:FacebookTwitterLike this:Like Loading…