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]

名前グループ
1アルバolympic
2アフガニスタンun, olympic
3アンゴラun, olympic
4アンギラ
5オーランド諸島
6アルバニアun, olympic
7アンドラun, olympic
8アラブ首長国連邦un, olympic
9アルゼンチンun, olympic
10アルメニアun, olympic
11アメリカ領サモアolympic
12南極
13フランス南部領
14アンティグア・バーブーダun, olympic
15オーストラリアun, olympic
16オーストリアun, olympic
17アゼルバイジャンun, olympic
18ブルンジun, olympic
19ベルギーun, olympic
20ベナンun, olympic
21ボネール、セント・ユースタティウス、サバ
22ブルキナファソun, olympic
23バングラデシュun, olympic
24ブルガリアun, olympic
25バーレーンun, olympic
26バハマun, olympic
27ボスニア・ヘルツェゴビナun, olympic
28サン・バルテルミー
29ベラルーシun, olympic
30ベリーズun, olympic
31バミューダolympic
32ボリビア多民族国un, olympic
33ブラジルun, olympic
34バルバドスun, olympic
35ブルネイ・ダルサラムun, olympic
36ブータンun, olympic
37ブーベ島
38ボツワナun, olympic
39中央アフリカ共和国un, olympic
40カナダun, olympic
41ココス (キーリング) 諸島
42スイスun, olympic
43チリun, olympic
44中国un, olympic
45コートジボワールun, olympic
46カメルーンun, olympic
47コンゴ民主共和国un, olympic
48コンゴ共和国un, olympic
49クック諸島olympic
50コロンビアun, olympic
51コモロun, olympic
52カーボベルデun, olympic
53コスタリカun, olympic
54キューバun, olympic
55キュラソー島
56クリスマス島
57ケイマン諸島olympic
58キプロスun, olympic
59チェコ共和国un, olympic
60ドイツun, olympic
61ジブチun, olympic
62ドミニカun, olympic
63デンマークun, olympic
64ドミニカ共和国un, olympic
65アルジェリアun, olympic
66エクアドルun, olympic
67エジプトun, olympic
68エリトリアun, olympic
69西サハラ
70スペインun, olympic
71エストニアun, olympic
72エチオピアun, olympic
73フィンランドun, olympic
74フィジーun, olympic
75フォークランド諸島 (マルビナス諸島)
76フランスun, olympic
77フェロー諸島
78ミクロネシア連邦un, olympic
79ガボンun, olympic
80イギリスun, olympic
81ジョージアun, olympic
82ガーンジー
83ガーナun, olympic
84ジブラルタル
85ギニアun, olympic
86グアドループ
87ガンビアun, olympic
88ギニアビサウun, olympic
89赤道ギニア共和国un, olympic
90ギリシャun, olympic
91グレナダun, olympic
92グリーンランド
93グアテマラun, olympic
94仏領ギアナ
95グアムolympic
96ガイアナun, olympic
97香港olympic
98ハード島とマクドナルド諸島
99ホンジュラスun, olympic
100クロアチアun, olympic
101ハイチun, olympic
102ハンガリーun, olympic
103インドネシアun, olympic
104マン島
105インドun, olympic
106イギリス領インド洋地域
107アイルランドun, olympic
108イラン・イスラム共和国un, olympic
109イラクun, olympic
110アイスランドun, olympic
111イスラエルun, olympic
112イタリアun, olympic
113ジャマイカun, olympic
114ジャージー
115ヨルダンun, olympic
116日本un, olympic
117カザフスタンun, olympic
118ケニアun, olympic
119キルギスタンun, olympic
120コロンビアun, olympic
121キリバスun, olympic
122セントクリストファー・ネイビスun, olympic
123韓国 (大韓民国)un, olympic
124クウェートun, olympic
125ラオス人民民主共和国un, olympic
126レバノンun, olympic
127リベリアun, olympic
128リビアun, olympic
129セントルシアun, olympic
130リヒテンシュタインun, olympic
131スリランカun, olympic
132レソトun, olympic
133リトアニアun, olympic
134ルクセンブルクun, olympic
135ラトビアun, olympic
136マカオ
137セント・マーチン島 (フランス領)
138モロッコun, olympic
139モナコun, olympic
140モルドバ共和国un, olympic
141マダガスカルun, olympic
142モルディブun, olympic
143メキシコun, olympic
144マーシャル諸島un, olympic
145マケドニア旧ユーゴスラビア共和国un, olympic
146マリun, olympic
147マルタun, olympic
148ミャンマーun, olympic
149モンテネグロun, olympic
150モンゴルun, olympic
151北マリアナ諸島連邦
152モザンビークun, olympic
153モーリタニアun, olympic
154モントセラト
155マルティニーク
156モーリシャスun, olympic
157マラウィun, olympic
158マレーシアun, olympic
159マヨット
160ナミビアun, olympic
161ニューカレドニア
162ニジェールun, olympic
163ノーフォーク島
164ナイジェリアun, olympic
165ニカラグアun, olympic
166ニウエ
167オランダun, olympic
168ノルウェーun, olympic
169ネパールun, olympic
170ナウルun, olympic
171ニュージーランドun, olympic
172オマーンun, olympic
173パキスタンun, olympic
174パナマun, olympic
175ピトケアン
176ペルーun, olympic
177フィリピンun, olympic
178パラオun, olympic
179パプアニューギニアun, olympic
180ポーランドun, olympic
181プエルトリコolympic
182朝鮮民主主義人民共和国un, olympic
183ポルトガルun, olympic
184パラグアイun, olympic
185パレスチナ自治政府olympic
186仏領ポリネシア
187カタールun, olympic
188レユニオン
189ルーマニアun, olympic
190ロシア連邦un, olympic
191ルワンダun, olympic
192サウジアラビアun, olympic
193スーダンun, olympic
194セネガルun, olympic
195シンガポールun, olympic
196サウスジョージア・サウスサンドウィッチ諸島
197セントヘレナ・アセンションおよびトリスタンダクーニャ
198スバールバル諸島ヤンマイエン島
199ソロモン諸島un, olympic
200シエラレオネun, olympic
201エルサルバドルun, olympic
202サンマリノun, olympic
203ソマリアun, olympic
204サンピエール島・ミクロン島
205セルビアun, olympic
206南スーダンun, olympic
207サントメ・プリンシペ民主共和国un, olympic
208スリナムun, olympic
209スロバキアun, olympic
210スロベニアun, olympic
211スウェーデンun, olympic
212スワジランドun, olympic
213セント・マーチン島 (オランダ領)
214セーシェルun, olympic
215シリアアラブ共和国un, olympic
216タークス・カイコス諸島
217チャドun, olympic
218トーゴun, olympic
219タイun, olympic
220タジキスタンun, olympic
221トケラウ
222トルクメニスタンun, olympic
223東ティモールun, olympic
224トンガun, olympic
225トリニダードトバゴun, olympic
226チュニジアun, olympic
227トルコun, olympic
228ツバルun, olympic
229台湾省olympic
230タンザニア連合共和国un, olympic
231ウガンダun, olympic
232ウクライナun, olympic
233アメリカ合衆国外諸島
234ウルグアイun, olympic
235アメリカun, olympic
236ウズベキスタンun, olympic
237バチカン市国
238セントビンセント・グレナディーンun, olympic
239ベネズエラ・ボリバル共和国un, olympic
240イギリス領ヴァージン諸島olympic
241アメリカ領ヴァージン諸島olympic
242ベトナムun, olympic
243バヌアツun, olympic
244ウォリス・フツナ
245サモアun, olympic
246イエメンun, olympic
247南アフリカun, olympic
248ザンビアun, olympic
249ジンバブエun, 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]

名前グループ
1Alaskastates
2Alabamastates
3Arkansasstates
4American Samoaoutlying_areas
5Arizonastates
6Californiastates
7Coloradostates
8Connecticutstates
9District of Columbiadistricts
10Delawarestates
11Floridastates
12Georgiastates
13Guamoutlying_areas
14Hawaiistates
15Iowastates
16Idahostates
17Illinoisstates
18Indianastates
19Kansasstates
20Kentuckystates
21Louisianastates
22Massachusettsstates
23Marylandstates
24Mainestates
25Michiganstates
26Minnesotastates
27Missouristates
28Northern Mariana Islandsoutlying_areas
29Mississippistates
30Montanastates
31North Carolinastates
32North Dakotastates
33Nebraskastates
34New Hampshirestates
35New Jerseystates
36New Mexicostates
37Nevadastates
38New Yorkstates
39Ohiostates
40Oklahomastates
41Oregonstates
42Pennsylvaniastates
43Puerto Ricooutlying_areas
44Rhode Islandstates
45South Carolinastates
46South Dakotastates
47Tennesseestates
48Texasstates
49United States Minor Outlying Islandsoutlying_areas
50Utahstates
51Virginiastates
52Virgin Islands, U.S.outlying_areas
53Vermontstates
54Washingtonstates
55Wisconsinstates
56West Virginiastates
57Wyomingstates
Currencies [currencies]

A list of currencies based on the ISO 4217 standard.

Usage example:
[select your-currency data:currencies]

名前グループ
1United Arab Emirates dirham
2Afghan afghani
3Albanian lek
4Armenian dram
5Netherlands Antillean guilder
6Angolan kwanza
7Argentine peso
8Australian dollar
9Aruban florin
10Azerbaijani manat
11Bosnia and Herzegovina convertible mark
12Barbados dollar
13Bangladeshi taka
14Bulgarian lev
15Bahraini dinar
16Burundian franc
17Bermudian dollar
18Brunei dollar
19Boliviano
20Brazilian real
21Bahamian dollar
22Bhutanese ngultrum
23Botswana pula
24Belarusian ruble
25Belize dollar
26Canadian dollar
27Congolese franc
28Swiss franc
29Chilean peso
30Chinese yuan
31Colombian peso
32Costa Rican colon
33Cuban peso
34Cape Verde escudo
35Czech koruna
36Djiboutian franc
37Danish krone
38Dominican peso
39Algerian dinar
40Egyptian pound
41Eritrean nakfa
42Ethiopian birr
43Euro
44Fiji dollar
45Falkland Islands pound
46Pound sterling
47Georgian lari
48Ghanaian cedi
49Gibraltar pound
50Gambian dalasi
51Guinean franc
52Guatemalan quetzal
53Guyanese dollar
54Hong Kong dollar
55Honduran lempira
56Croatian kuna
57Haitian gourde
58Hungarian forint
59Indonesian rupiah
60Israeli new shekel
61Indian rupee
62Iraqi dinar
63Iranian rial
64Icelandic króna
65Jamaican dollar
66Jordanian dinar
67Japanese yen
68Kenyan shilling
69Kyrgyzstani som
70Cambodian riel
71Comoro franc
72North Korean won
73South Korean won
74Kuwaiti dinar
75Cayman Islands dollar
76Kazakhstani tenge
77Lao kip
78Lebanese pound
79Sri Lankan rupee
80Liberian dollar
81Lesotho loti
82Lithuanian litas
83Libyan dinar
84Moroccan dirham
85Moldovan leu
86Malagasy ariary
87Macedonian denar
88Myanma kyat
89Mongolian tugrik
90Macanese pataca
91Mauritanian ouguiya
92Mauritian rupee
93Maldivian rufiyaa
94Malawian kwacha
95Mexican peso
96Malaysian ringgit
97Mozambican metical
98Namibian dollar
99Nigerian naira
100Nicaraguan córdoba
101Norwegian krone
102Nepalese rupee
103New Zealand dollar
104Omani rial
105Panamanian balboa
106Peruvian nuevo sol
107Papua New Guinean kina
108Philippine peso
109Pakistani rupee
110Polish złoty
111Paraguayan guaraní
112Qatari riyal
113Romanian new leu
114Serbian dinar
115Russian ruble
116Rwandan franc
117Saudi riyal
118Solomon Islands dollar
119Seychelles rupee
120Sudanese pound
121Swedish krona/kronor
122Singapore dollar
123Saint Helena pound
124Sierra Leonean leone
125Somali shilling
126Surinamese dollar
127South Sudanese pound
128São Tomé and Príncipe dobra
129Syrian pound
130Swazi lilangeni
131Thai baht
132Tajikistani somoni
133Turkmenistani manat
134Tunisian dinar
135Tongan paʻanga
136Turkish lira
137Trinidad and Tobago dollar
138New Taiwan dollar
139Tanzanian shilling
140Ukrainian hryvnia
141Ugandan shilling
142United States dollar
143Uruguayan peso
144Uzbekistan som
145Venezuelan bolívar
146Vietnamese dong
147Vanuatu vatu
148Samoan tala
149CFA franc BEAC
150East Caribbean dollar
151CFA franc BCEAO
152CFP franc (franc Pacifique)
153Yemeni rial
154South African rand
155Zambian kwacha
156Zimbabwe dollar

WordPress のお問い合わせフォームプラグイン。シンプル、でも柔軟。

%d人のブロガーが「いいね」をつけました。