Zencart 国家排序及中文名称的扩展

2018-06-22 04:56:31来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

最终实现效果如上

具体步骤:

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;
  }

最终效果

如果不是特别需要,后台函数也可不修改。

   

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:PHP取当前年、月、日开始时间戳和下年、月、日开始时间戳函数

下一篇:wamp 两个不同的php.ini