최종 효과는 위와 같습니다
구체적인 단계:
1. 데이터 테이블을 수동으로 또는 SQL로 수정하고 필드 2개를 추가합니다
<span style="color: #0000ff;">ALTER</span> <span style="color: #0000ff;">TABLE</span> countries <span style="color: #0000ff;">ADD</span> `countries_name_cn` <span style="color: #0000ff;">VARCHAR</span>( <span style="color: #800000; font-weight: bold;">64</span> ) <span style="color: #0000ff;">NULL</span> <span style="color: #0000ff;">DEFAULT</span> <span style="color: #ff0000;">''</span>, <span style="color: #0000ff;">ADD</span> `order_by` <span style="color: #0000ff;">int</span>(<span style="color: #800000; font-weight: bold;">11</span>) <span style="color: #808080;">NOT</span> <span style="color: #0000ff;">NULL</span> <span style="color: #0000ff;">DEFAULT</span> <span style="color: #ff0000;">'</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">'</span>;
2. admin/countries.php 파일을 수정하고 양식 삽입 편집 기능을 추가합니다. 여기서는 특정 코드가 무시됩니다.
3. 그런 다음 국가 드롭다운 목록을 얻기 위해 두 가지 기능을 수정해야 합니다(각각 프론트엔드와 백엔드용)
#includes/functions/functions_lookups.php
<span style="color: #0000ff;">function</span> zen_get_countries(<span style="color: #800080;">$countries_id</span> = '', <span style="color: #800080;">$with_iso_codes</span> = <span style="color: #0000ff;">false</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">global</span> <span style="color: #800080;">$db</span><span style="color: #000000;">; </span><span style="color: #800080;">$countries_array</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #0000ff;">if</span> (zen_not_null(<span style="color: #800080;">$countries_id</span><span style="color: #000000;">)) { </span>~ ~<span style="color: #000000;"> } </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { </span><span style="color: #800080;">$countries</span> = "<span style="color: #000000;">select countries_id, countries_name, countries_name_cn from </span>" . TABLE_COUNTRIES . "<span style="color: #000000;"> order by order_by, countries_name</span>"<span style="color: #000000;">; </span><span style="color: #800080;">$countries_values</span> = <span style="color: #800080;">$db</span>->Execute(<span style="color: #800080;">$countries</span><span style="color: #000000;">); </span><span style="color: #0000ff;">while</span> (!<span style="color: #800080;">$countries_values</span>-><span style="color: #000000;">EOF) { </span><span style="color: #800080;">$countries_array</span>[] = <span style="color: #0000ff;">array</span>('countries_id' => <span style="color: #800080;">$countries_values</span>->fields['countries_id'], 'countries_name' => <span style="color: #800080;">$countries_values</span>->fields['countries_name']." - ".<span style="color: #800080;">$countries_values</span>->fields['countries_name_cn'<span style="color: #000000;">]); </span><span style="color: #800080;">$countries_values</span>-><span style="color: #000000;">MoveNext(); } } </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$countries_array</span><span style="color: #000000;">; }</span>
#admin/includes/functions/general.php
<span style="color: #0000ff;">function</span> zen_get_countries(<span style="color: #800080;">$default</span> = ''<span style="color: #000000;">) { </span><span style="color: #0000ff;">global</span> <span style="color: #800080;">$db</span><span style="color: #000000;">; </span><span style="color: #800080;">$countries_array</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$default</span><span style="color: #000000;">) { </span><span style="color: #800080;">$countries_array</span>[] = <span style="color: #0000ff;">array</span>('id' => '', 'text' => <span style="color: #800080;">$default</span><span style="color: #000000;">); } </span><span style="color: #800080;">$countries</span> = <span style="color: #800080;">$db</span>->Execute("<span style="color: #000000;">select countries_id, countries_name,countries_name_cn from </span>" . TABLE_COUNTRIES . "<span style="color: #000000;"> order by order_by, countries_name</span>"<span style="color: #000000;">); </span><span style="color: #0000ff;">while</span> (!<span style="color: #800080;">$countries</span>-><span style="color: #000000;">EOF) { </span><span style="color: #800080;">$countries_array</span>[] = <span style="color: #0000ff;">array</span>('id' => <span style="color: #800080;">$countries</span>->fields['countries_id'], 'text' => <span style="color: #800080;">$countries</span>->fields['countries_name']." - ".<span style="color: #800080;">$countries</span>->fields['countries_name_cn'<span style="color: #000000;">]); </span><span style="color: #800080;">$countries</span>-><span style="color: #000000;">MoveNext(); } </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$countries_array</span><span style="color: #000000;">; }</span>
최종 효과
특별히 필요하지 않은 경우에는 배경 기능을 수정할 필요가 없습니다.