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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[分享] 如何让房产首页搜索地区调用一级地区分类?[问题已解决]

[复制链接]
飞翔! 发表于 2010-12-22 22:59:13 | 显示全部楼层 |阅读模式
10微币
本帖最后由 飞翔! 于 2010-12-23 00:17 编辑

问题已解决,解决方法在二楼

如何让房产首页搜索地区调用一级地区分类?
现在显示的是二级地区分类.


后台删除了二级分类.我只使用一级分类.


在首页搜索栏这个地区位置如何显示一级分类..研究了好几天,更改调用数据还是失败,希望有高手帮忙.


在出租这一栏的地区中可以显示一级分类.只有首页不显示一级分类.





附件: 您需要 登录 才可以下载或查看,没有账号?立即注册
 楼主| 飞翔! 发表于 2010-12-23 00:04:56 | 显示全部楼层
问题已经解决.
下面是替换代码解决方法.
找到\source\function\目录下function_category.php该文件.
代码大约在920行左右.
复制以下代码进行替换

  1. //首页搜索区
  2. function searchindex($mod) {
  3. global $_G;

  4. $districtsearchlist = array();
  5. foreach($_G['cache']['category_arealist_'.$mod]['city'] as $aid => $city) {
  6. $citysearchlist[$aid] = $city;
  7. }

  8. $sortarray = $selectarray = array();
  9. $sorthtml = $selecthtml = $urlhtml = '';
  10. foreach($_G['cache']['category_sortlist_'.$mod] as $sortid => $sort) {
  11. $sortarray[$sortid]['name'] = $sort['name'];

  12. loadcache(array('category_option_'.$sortid));
  13. $sortoptionarray = $_G['cache']['category_option_'.$sortid];
  14. $quicksearchlist = quicksearch($sortoptionarray);
  15. $selectarray[$sortid] = $quicksearchlist;

  16. }
  17. return createhtml($sortarray, $selectarray, $citysearchlist);
  18. }

  19. function createhtml($sortarray, $selectarray, $citysearchlist) {
  20. $sorthtml = $selecthtml = $urlhtml = '';
  21. $displaynone = ' style="display:none;"';
  22. $firstsortid = 0;

  23. $sortcount = count($sortarray);
  24. $sorthtml = '<ul>';
  25. foreach($sortarray as $sortid => $sort) {
  26. if(empty($firstsortid)) {
  27. $firstsortid = $sortid;
  28. }
  29. if($sortid == $firstsortid) {
  30. $classhtml = 'class="a"';
  31. } else {
  32. $classhtml = 'class=""';
  33. }
  34. $sorthtml .= '<li id="searchsort_'.$sortid.'" '.$classhtml.' style="cursor:pointer;"><span onclick="changesort('.$sortid.', '.$sortcount.')">'.$sort['name'].'</span></li>';
  35. }
  36. $sorthtml .= '</ul>';

  37. foreach($selectarray as $sortid => $quicksearchlist) {
  38. $selecthtml .= '<div id="searchselect_'.$sortid.'" class="bbda cgs pns pbn cl"';
  39. if($sortid != $firstsortid) {
  40. $selecthtml .= $displaynone;
  41. }
  42. $selecthtml .= '><form method="post" autocomplete="off" name="searhsort" id="searhsort" action="house.php?mod=list&sortid='.$sortid.'">';
  43. foreach($quicksearchlist as $optionid => $option) {
  44. if(($option['type'] == 'select' && $option['choices']) || ($option['type'] == 'range' && $option['choices'])) {
  45. $selecthtml .= '<span class="ftid"><select name="searchoption['.$optionid.'][value]" id="'.$option['identifier'].'_'.$sortid.'"><option value="0">'.$option['title'].lang('block/categorylist', 'categorylist_any').'</option>';
  46. foreach($option['choices'] as $id => $value) {
  47. $selecthtml .= '<option value="'.$id.'">'.$value.'</option>';
  48. }
  49. $selecthtml .= '</select></span>';
  50. $selecthtml .= '<input type="hidden" name="searchoption['.$optionid.'][type]" value="'.$option['type'].'"><script type="text/javascript" reload="1">simulateSelect(\''.$option['identifier'].'_'.$sortid.'\');</script>';
  51. }
  52. if($option['type'] == 'text' && !$option['choices']) {
  53. $selecthtml .= '<input type="hidden" name="searchoption['.$optionid.'][type]" value="'.$option['type'].'"><input type="text" name="searchoption['.$optionid.'][value]" size="15" id="'.$option['identifier'].'_'.$sortid.'" class="px" value="'.$option['title'].'" onclick="$(\''.$option['identifier'].'_'.$sortid.'\').value = \'\'" />';
  54. }
  55. }
  56. $selecthtml .= '<button type="submit" class="pn" name="searchsortsubmit"><em>'.lang('block/categorylist', 'categorylist_submit').'</em></button></form>';
  57. $selecthtml .= '</div>';
  58. }

  59. foreach($selectarray as $sortid => $quicksearchlist) {
  60. $urlhtml .= '<div class="cgsq ptn pbm" id="url_'.$sortid.'"';
  61. if($sortid != $firstsortid) {
  62. $urlhtml .= $displaynone;
  63. }
  64. $urlhtml .= '><dl class="cl"><dt>';
  65. $urlhtml .= lang('block/categorylist', 'categorylist_area').': </dt><dd><ul>';
  66. foreach($citysearchlist as $did => $city) {
  67. $urlhtml .= '<li><a href="house.php?mod=list&filter=all&city='.$did.'&sortid='.$sortid.'">'.$city.'</a></li>';
  68. }
  69. $urlhtml .= '</ul></dd></dl>';
  70. foreach($quicksearchlist as $optionid => $option) {
  71. if(in_array($option['type'], array('select', 'radio')) || ($option['type'] == 'range' && $option['choices'])) {
  72. $urlhtml .= '<dl class="cl"><dt>'.$option['title'].':</dt><dd><ul>';
  73. foreach($option['choices'] as $id => $value) {
  74. $urlhtml .= '<li><a href="house.php?mod=list&filter=all&sortid='.$sortid.'&'.$option['identifier'].'='.$id.'">'.$value.'</a></li>';
  75. }
  76. $urlhtml .= '</ul></dd></dl>';
  77. }
  78. }
  79. $urlhtml .= '</div>';
  80. }
  81. return array('sorthtml' => $sorthtml, 'otherhtml' => $selecthtml.$urlhtml);
  82. }
复制代码

从这里开始

//首页搜索区
function searchindex($mod) {
global $_G;


到以下结尾

$selecthtml.$urlhtml);
}


整个部分全部替换..
OK问题解决.

评分

1

查看全部评分

回复

使用道具 举报

nirending 发表于 2010-12-23 15:34:29 | 显示全部楼层
收藏了,谢谢!
回复

使用道具 举报

小义哥 发表于 2010-12-23 18:43:29 | 显示全部楼层
此方法是好像不对的朋友
回复

使用道具 举报

 楼主| 飞翔! 发表于 2010-12-23 21:19:47 | 显示全部楼层
回复 小义哥 的帖子

测试通过,请详细阅读替换方法。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-28 20:12 , Processed in 0.193497 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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