本帖最后由 whj888 于 2009-3-27 21:08 编辑
省市县三级联动插件 UCH1.5正式版
首先感谢 zsycnc 提供的UCH1.2省市县三级联动插件修改。
原帖地址:https://discuz.dismall.com/viewthread ... %C1%AA%B6%AF&page=1
与学校信息UCH1.5正式版 https://discuz.dismall.com/thread-1144984-1-1.html 可以一起使用,互不冲突。
需要地区性的三级联动,可以在此基础上修改JS文件即可。
主要改进:
1、用户在设置地址信息后,打开个人资料页可自动显示。
2、修正了我已知的地址错误信息。(js文件更新于2006年,由于时间关系不能一一检查,希望有高手把JS地址批量更新到最新,原来在论坛看到有一位朋友进行过更新工作,可惜我找不到了,若哪位朋友能找到最新的JS请告之)
改动较多,请先备份相关文件。看不明白修改方法的可看6楼的非code版,红色字为改动部分。附件还提供了修改过的文件,如果相关文件你没有修改过可直接覆盖。最后还提供了学校信息和省市区三级联动的共同文件。(建议手工修改!实在改不了的,备份后覆盖试试。)
修改方法:
一、增加数据字段:
用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、修改cp_profile.htm- <th>家乡</th>
- <td>
- <script language="javascript" src="source/pcasunzip.js"></script>
- <select name="birthprovince" >
- </select>
- <select name="birthcity" >
- </select>
- <select name="birthsubcity" >
- </select>
- <script language="javascript" defer="defer">
- <!--
- new PCAS("birthprovince","birthcity","birthsubcity","$space[birthprovince]","$space[birthcity]","$space[birthsubcity]");
- //-->
- </script>
- </td>
- </tr>
- <tr>
- <th>居住地</th>
- <td>
- <select name="resideprovince">
- </select>
- <select name="residecity" tabindex="123">
- </select>
- <select name="residesubcity" >
- </select>
- <script type="text/javascript" defer="defer">
- <!--
- new PCAS("resideprovince","residecity","residesubcity","$space[resideprovince]","$space[residecity]","$space[residesubcity]");
- //-->
- </script>
-
- </td>
- </tr>
复制代码 2、修改 cp_friend.htm- <th>家乡</th>
- <td>
- <script language="javascript" src="source/pcasunzip.js"></script>
- <select name="birthprovince"></select><select name="birthcity" ></select><select name="birthsubcity" ></select>
- <script language="javascript" defer="defer">
- new PCAS("birthprovince","birthcity","birthsubcity");
- </script>
- </td>
- </tr>
- <tr>
- <th>居住地</th>
- <td>
- <select name="resideprovince"></select><select name="residecity" tabindex="123"></select><select name="residesubcity" ></select>
- <script type="text/javascript" defer="defer">
- <!--
- new PCAS("resideprovince","residecity","residesubcity");
- //-->
- </script>
-
- </td>
- </tr>
复制代码 3、修改 network_space.htm- <th>家乡</th>
- <td>
- <script language="javascript" src="source/pcasunzip.js"></script>
- <select name="birthprovince"></select><select name="birthcity" ></select><select name="birthsubcity" ></select>
- <script language="javascript" defer="defer">
- new PCAS("birthprovince","birthcity","birthsubcity");
- </script>
- </td>
- </tr>
- <tr>
- <th>居住地</th>
- <td>
- <select name="resideprovince"></select><select name="residecity" tabindex="123"></select><select name="residesubcity" ></select>
- <script type="text/javascript" defer="defer">
- <!--
- new PCAS("resideprovince","residecity","residesubcity");
- //-->
- </script>
-
- </td>
- </tr>
复制代码 4、修改source/space_index.php- //个人资料
- //性别
- $space['birth'] = trim(($space['birthprovince']?"<a href="network.php?ac=space&birthprovince=".rawurlencode($space['birthprovince'])."&searchmode=1">$space[birthprovince]</a>":'').($space['birthcity']?" <a href="network.php?ac=space&birthcity=".rawurlencode($space['birthcity'])."&searchmode=1">$space[birthcity]</a>":'').($space['birthsubcity']?" <a href="network.php?ac=space&birthsubcity=".rawurlencode($space['birthsubcity'])."&searchmode=1">$space[birthsubcity]</a>":''));
- $space['reside'] = trim(($space['resideprovince']?"<a href="network.php?ac=space&resideprovince=".rawurlencode($space['resideprovince'])."&searchmode=1">$space[resideprovince]</a>":'').($space['residecity']?" <a href="network.php?ac=space&residecity=".rawurlencode($space['residecity'])."&searchmode=1">$space[residecity]</a>":'').($space['residesubcity']?" <a href="network.php?ac=space&residesubcity=".rawurlencode($space['residesubcity'])."&searchmode=1">$space[residesubcity]</a>":''));
复制代码 5、修改 source/network_space.php- //开始搜索
- $wherearr = array();
- foreach (array('sex', 'birthyear', 'birthmonth', 'birthday', 'marry', 'blood', 'birthprovince', 'birthcity','birthsubcity', 'resideprovince', 'residecity','residesubcity', 'qq', 'msn') as $value)
- //判断是否搜索太快
- $gets['birthprovince'] = empty($_GET['birthprovince'])?'':stripsearchkey($_GET['birthprovince']);
- $gets['birthcity'] = empty($_GET['birthcity'])?'':stripsearchkey($_GET['birthcity']);
- $gets['birthsubcity'] = empty($_GET['birthsubcity'])?'':stripsearchkey($_GET['birthsubcity']);
- $gets['resideprovince'] = empty($_GET['resideprovince'])?'':stripsearchkey($_GET['resideprovince']);
- $gets['residecity'] = empty($_GET['residecity'])?'':stripsearchkey($_GET['residecity']);
- $gets['residesubcity'] = empty($_GET['residesubcity'])?'':stripsearchkey($_GET['residesubcity']);
复制代码 6、修改source/cp_profile.php- //提交检查
- //增加下面的(放在最后,注意最后一个没有逗号)
- 'birthsubcity' => getstr($_POST['birthsubcity'], 20, 1, 1),
- 'residesubcity' => getstr($_POST['residesubcity'], 20, 1, 1)
复制代码 三、上传JS文件:
把附件 pcasunzip.rar 中JS文件解压,上传到source文件夹中。
我把修改过程的文本文件一起上传了,可参照文本文件进行修改。修改地方比较多,请认真对照原来的代码修改. |