Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

居住地、家乡 ★省★市★县三级联动(免费)

[复制链接]
很想学习 发表于 2009-9-19 15:22:48 | 显示全部楼层 |阅读模式
UCHome插件
语言编码: GBK简体 
插件名称: 居住地、家乡 ★省★市★县三级联动
插件作者:
适用版本: UCHome 2.0
做人要厚道,感谢原帖作者,地址是:
★省★市★地区◆三级联动◆(1.5正式版) 可扩展!

经过研究修改现在适用2.0版本。

0.下载js文件上传js
到文件夹
source/js/里
然后升级数据库

增加数据字段:
用phpmyadmin在uhome数据库的“uchome_spacefield”表里面添加两个字段:
birthsubcity和residesubcity,类型:varchar(20)


SQL语句:
  
ALTER TABLE `uchome_spacefield` ADD `birthsubcity` VARCHAR( 20 ) NOT NULL AFTER `birthcity` ;
ALTER TABLE `uchome_spacefield` ADD `residesubcity` VARCHAR( 20 ) NOT NULL AFTER `residecity` ;


修改地方比较多,请认真对照原来的代码修改.
1.admincp_space.php
①找到:
'birthcity' => getstr($_POST['birthcity'], 20, 1, 1),

下加:
'birthsubcity' => getstr($_POST['birthsubcity'], 20, 1, 1),

②找到:
'residecity' => getstr($_POST['residecity'], 20, 1, 1),
下加:


'residesubcity' => getstr($_POST['residesubcity'], 20, 1, 1),
2.admin/tpl/space_manage.htm
①找到:
<th>家乡</th>
   <td id="birthcitybox">
    <script type="text/javascript" src="source/script_city.js"></script>
    <script type="text/javascript">
    <!--
    showprovince('birthprovince', 'birthcity', '$member[birthprovince]',

'birthcitybox');
    showcity('birthcity', '$member[birthcity]', 'birthprovince', 'birthcitybox');
   
    //-->
    </script>
   </td>
  </tr>
  <tr>
   <th>居住地</th>
   <td id="residecitybox">
    <script type="text/javascript">
    <!--
    showprovince('resideprovince', 'residecity', '$member[resideprovince]',

'residecitybox');
    showcity('residecity', '$member[residecity]', 'resideprovince',

'residecitybox');
    //-->
    </script>
   </td>
  </tr>
  <tr>


②改为:
<th>家乡:</th>
<td id="birthcitybox">
  <script type="text/javascript" src="source/js/script_city2.js"></script>
  <script type="text/javascript">
   var $ = function(ID){ return document.getElementById(ID); };
   window.onload = function() {
    attachSelect(0, [$("a"), $("b"), $("c")], aMatrix, ["$space

[birthprovince]","$space[birthcity]","$space[birthsubcity]",]);
    attachSelect(0, [$("d"), $("e"), $("f")], aMatrix, ["$space

[resideprovince]","$space[residecity]","$space[residesubcity]",]);
   };
  </script>
  <select id="a" name="birthprovince">--</select>
  <select id="b" name="birthcity">--</select>
  <select id="c" name="birthsubcity">--</select>
</td>
</tr>
<tr>
<th>居住地:</th>
<td id="residecitybox">
    <select id="d" name="resideprovince">--</select>
    <select id="e" name="residecity">--</select>
   <select id="f" name="residesubcity">--</select>
</td>
</tr>
  <tr>

3.template/default/cp_friend.htm
①找到:
<!--{template header}-->

下加:
<script type="text/javascript" src="source/js/script_city2.js"></script>

②找到:
<td align="right">居住地:</td>
   <td id="residecitybox"></td>
  </tr>
  
  <tr>
   <td align="right">出生地:</td>
   <td id="birthcitybox"></td>
  </tr>
  
  <script type="text/javascript" src="source/script_city.js"></script>
  <script type="text/javascript">
  <!--
  showprovince('resideprovince', 'residecity', '', 'residecitybox');
  showcity('residecity', '', 'resideprovince', 'residecitybox');
  showprovince('birthprovince', 'birthcity', '', 'birthcitybox');
  showcity('birthcity', '', 'birthprovince', 'birthcitybox');
  //-->
  </script>
<tr>

改为:
<td align="right">居住地:</td>
   <td id="residecitybox">
    <script type="text/javascript">
     var $ = function(ID){ return document.getElementById(ID); };
     window.onload = function() {
                   attachSelect(0, [$("a"), $("b"), $("c")], aMatrix, ["$space

[birthprovince]","$space[birthcity]","$space[birthsubcity]",]);
                   attachSelect(0, [$("d"), $("e"), $("f")], aMatrix, ["$space

[resideprovince]","$space[residecity]","$space[residesubcity]",]);
     };
    </script>
                 <select id="d" name="resideprovince">--</select>
                 <select id="e" name="residecity">--</select>
                 <select id="f" name="residesubcity">--</select>
</td>
  </tr>
  
  <tr>
   <td align="right">出生地:</td>
   <td id="birthcitybox">
                 <select id="a" name="birthprovince">--</select>
                 <select id="b" name="birthcity">--</select>
                 <select id="c" name="birthsubcity">--</select>
</td>
  </tr>
  

  
  <tr>


③查找:
<td align="right" width="150">居住地:</td>
   <td id="residecitybox"></td>
  </tr>

改为:
<td align="right" width="150">居住地:</td>
   <td id="residecitybox">
    <script type="text/javascript">
     var $ = function(ID){ return document.getElementById(ID); };
     window.onload = function() {
      attachSelect(0, [$("rp"), $("rc"), $("rsc")], aMatrix,

["$space[resideprovince]","$space[residecity]","$space[residesubcity]",]);     
      attachSelect(0, [$("bp"), $("bc"), $("bsc")], aMatrix,

["$space[birthprovince]","$space[birthcity]","$space[birthsubcity]",]);
     };
    </script>  
                 <select id="rp" name="resideprovince">--</select>
                 <select id="rc" name="residecity">--</select>
                 <select id="rsc" name="residesubcity">--</select>
</td>
  </tr>
④查找删除(三处全删)
<script type="text/javascript" src="source/script_city.js"></script>
  <script type="text/javascript">
  <!--
  showprovince('resideprovince', 'residecity', '$space[resideprovince]', 'residecitybox');
  showcity('residecity', '$space[residecity]', 'resideprovince', 'residecitybox');
  //-->
  </script>

4.template/default/cp_profile.htm
①查找:
<script type="text/javascript" src="source/script_city.js"></script>
  <script type="text/javascript">
  <!--
  showprovince('birthprovince', 'birthcity', '$space[birthprovince]', 'birthcitybox');
  showcity('birthcity', '$space[birthcity]', 'birthprovince', 'birthcitybox');
  
  //-->
  </script>

修改为:
<script type="text/javascript" src="source/js/script_city2.js"></script>
  <script type="text/javascript">
   var $ = function(ID){ return document.getElementById(ID); };
   window.onload = function() {
    attachSelect(0, [$("a"), $("b"), $("c")], aMatrix, ["$space

[birthprovince]","$space[birthcity]","$space[birthsubcity]",]);
    attachSelect(0, [$("d"), $("e"), $("f")], aMatrix, ["$space

[resideprovince]","$space[residecity]","$space[residesubcity]",]);
   };
  </script>
                <select id="a" name="birthprovince">--</select>
  <select id="b" name="birthcity">--</select>
  <select id="c" name="birthsubcity">--</select>


②查找:
<th>居住地:</th>
<td id="residecitybox">
<script type="text/javascript">
  <!--
  showprovince('resideprovince', 'residecity', '$space[resideprovince]', 'residecitybox');
  showcity('residecity', '$space[residecity]', 'resideprovince', 'residecitybox');
  //-->
  </script>

修改为:
                                <select id="d" name="resideprovince">--</select>
    <select id="e" name="residecity">--</select>
    <select id="f" name="residesubcity">--</select>

5.source/cp_profile.php
①.找到:
'birthcity' => getstr($_POST['birthcity'], 20, 1, 1),
下加:

'birthsubcity' => getstr($_POST['birthsubcity'], 20, 1, 1),
②.找到:
'residecity' => getstr($_POST['residecity'], 20, 1, 1)后加,(否则白屏)

下加:
'residesubcity' => getstr($_POST['residesubcity'], 20, 1, 1)
  );

6.source/space_index.php
①.找到:
"&searchmode=1\">$space[birthcity]</a>":''));将其中的);


改为:
.($space['birthsubcity']?" <a href=\"cp.php?ac=friend&op=search&birthsubcity=".rawurlencode($space

['birthsubcity'])."&searchmode=1\">$space[birthsubcity]</a>":''));
②.再找
"&searchmode=1\">$space[residecity]</a>":''));将其中的);

改为:
.($space['residesubcity']?" <a href=\"cp.php?ac=friend&op=search&residesubcity=".rawurlencode($space

['residesubcity'])."&searchmode=1\">$space[residesubcity]</a>":''));

7.source/cp_friend.php
①.找到:
'birthcity'
后加:
,'birthsubcity'

②.再找'residecity'
后加:,'residesubcity'
8.source/space_info.php

找到:
&searchmode=1\">$space[birthcity]</a>":''));
将其中的);
改为:
').($space['birthsubcity']?" <a href=\"cp.php?ac=friend&op=search&birthsubcity=".rawurlencode($space

['birthsubcity'])."&searchmode=1\">$space[birthsubcity]</a>":''));
再找
&searchmode=1\">$space[residecity]</a>":''));

将其中的);
改为:
.($space['residesubcity']?" <a href=\"cp.php?ac=friend&op=search&residesubcity=".rawurlencode($space

['residesubcity'])."&searchmode=1\">$space[residesubcity]</a>":''));

9.source/task/profile.php
找到:
'birthcity' => '家乡(市)',

下加:
'birthsubcity' => '家乡(区/县/旗)',

再找:
'residecity' => '居住地(市)',

下加:
'residesubcity' => '居住(区/县/旗)'
10.完成,更新缓存。
回复

使用道具 举报

 楼主| 很想学习 发表于 2009-9-19 15:30:29 | 显示全部楼层
增加个演示
回复

使用道具 举报

 楼主| 很想学习 发表于 2009-9-19 15:36:14 | 显示全部楼层
演示:
回复

使用道具 举报

huaxuanso 发表于 2009-9-19 15:58:15 | 显示全部楼层
知道怎么调用啊。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-9-14 07:47 , Processed in 0.110212 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表