最終實現效果如上
具體步驟:
1. 手動或SQL修改數據表,增加2個字段
ALTER TABLE countries ADD `countries_name_cn` VARCHAR( 64 ) NULL DEFAULT '', ADD `order_by` int(11) NOT NULL DEFAULT '0';
2. 修改admin/countries.php文件,增加表單插入編輯功能, 共計7處,此處忽略具體代碼。
3. 之後還要修改兩個獲取國家下拉列表的函數(前台後台分別對應一個)
#includes/functions/functions_lookups.php
function zen_get_countries($countries_id = '', $with_iso_codes = false) { global $db; $countries_array = array(); if (zen_not_null($countries_id)) { ~ ~ } else { $countries = "select countries_id, countries_name, countries_name_cn from " . TABLE_COUNTRIES . " order by order_by, countries_name"; $countries_values = $db->Execute($countries); while (!$countries_values->EOF) { $countries_array[] = array('countries_id' => $countries_values->fields['countries_id'], 'countries_name' => $countries_values->fields['countries_name']." - ".$countries_values->fields['countries_name_cn']); $countries_values->MoveNext(); } } return $countries_array; }
#admin/includes/functions/general.php
function zen_get_countries($default = '') { global $db; $countries_array = array(); if ($default) { $countries_array[] = array('id' => '', 'text' => $default); } $countries = $db->Execute("select countries_id, countries_name,countries_name_cn from " . TABLE_COUNTRIES . " order by order_by, countries_name"); while (!$countries->EOF) { $countries_array[] = array('id' => $countries->fields['countries_id'], 'text' => $countries->fields['countries_name']." - ".$countries->fields['countries_name_cn']); $countries->MoveNext(); } return $countries_array; }
最終效果
如果不是特別需要,後台函數也可不修改。