PHPCMS数据筛选功能实现

时间:2025-01-06 10:36:20
第一步:添加模型字段,这个模型可以是官方的,也可以是你自定义的模型,以单选字段形式添加就好了;

第二步:就是添加栏目和内容;

第三步:模板如下,照着改就好了。

  1. {template "content","header"}
  2. <!-- 开始取出字段--------------------------------------------- -->
  3. {pc:get sql="SELECT * FROM `v9_model_field` where `field`='fangshi' and `modelid`='3'" return="data"}
  4. <?php
  5. $optionsn='';
  6. eval("\$setting_arr =".$data[0]['setting'].";");
  7. $optionsn=explode("\n",$setting_arr['options']);
  8. $fangshi_array=array(); //修改这个地方
  9. foreach( $optionsn as $kk=>$vv){
  10. $optionsn_vv=explode("|",$vv);
  11. $fangshi_array[trim($optionsn_vv[1])]=trim($optionsn_vv[0]); //修改这个地方
  12. }
  13. ?>
  14. {/pc}
  15. {pc:get sql="SELECT * FROM `v9_model_field` where `field`='paytype' and `modelid`='3'" return="data"}
  16. <?php
  17. $optionsn='';
  18. eval("\$setting_arr =".$data[0]['setting'].";");
  19. $optionsn=explode("\n",$setting_arr['options']);
  20. $paytype_array=array(); //修改这个地方
  21. foreach( $optionsn as $kk=>$vv){
  22. $optionsn_vv=explode("|",$vv);
  23. $paytype_array[trim($optionsn_vv[1])]=trim($optionsn_vv[0]); //修改这个地方
  24. }
  25. ?>
  26. {/pc}
  27. {pc:get sql="SELECT * FROM `v9_model_field` where `field`='housetype' and `modelid`='3'" return="data"}
  28. <?php
  29. $optionsn='';
  30. eval("\$setting_arr =".$data[0]['setting'].";");
  31. $optionsn=explode("\n",$setting_arr['options']);
  32. $housetype_array=array(); //修改这个地方
  33. foreach( $optionsn as $kk=>$vv){
  34. $optionsn_vv=explode("|",$vv);
  35. $housetype_array[trim($optionsn_vv[1])]=trim($optionsn_vv[0]); //修改这个地方
  36. }
  37. ?>
  38. {/pc}
  39. {pc:get sql="SELECT * FROM `v9_model_field` where `field`='dingshi' and `modelid`='3'" return="data"}
  40. <?php
  41. $optionsn='';
  42. eval("\$setting_arr =".$data[0]['setting'].";");
  43. $optionsn=explode("\n",$setting_arr['options']);
  44. $dingshi_array=array(); //修改这个地方
  45. foreach( $optionsn as $kk=>$vv){
  46. $optionsn_vv=explode("|",$vv);
  47. $dingshi_array[trim($optionsn_vv[1])]=trim($optionsn_vv[0]); //修改这个地方
  48. }
  49. ?>
  50. {/pc}
  51. <!-- 结束取出字段--------------------------------------------- -->
  52. 织梦模板,phpcms模板免费下载 http://www.bbscms.net
  53. <!-- 开始拼装where -->
  54. <?php
  55. $where="";
  56. if(!empty($_GET['fangshi'])){
  57. $where.="`fangshi` = '".$_GET['fangshi']."' AND ";
  58. }
  59. if(!empty($_GET['paytype'])){
  60. $where.="`paytype` = '".$_GET['paytype']."' AND ";
  61. }
  62. if(!empty($_GET['housetype'])){
  63. $where.="`housetype` = '".$_GET['housetype']."' AND ";
  64. }
  65. if(!empty($_GET['dingshi'])){
  66. $where.="`dingshi` = '".$_GET['dingshi']."' AND ";
  67. }
  68. $where.=1;
  69. ?>
  70. <!-- 结束拼装where -->
  71. <!--main-->
  72. <div class="main photo-channel">
  73. <div class="crumbs"><a href="{siteurl($siteid)}">首页</a><span> > {catpos($catid)}</div>
  74. <div class="bk10"></div>
  75. <style>
  76. .udiv{ margin-bottom:10px;}
  77. .ucurent{ background:#FF0; padding:2px; font-weight:bold;}
  78. </style>
  79. <div class="udiv"><strong>租房方式</strong>:
  80. <span><a href="{APP_PATH}index.php?m=content&c=index&a=lists&catid={$catid}&paytype={$_GET['paytype']}&housetype={$_GET['housetype']}&fangshi=&dingshi={$_GET['dingshi']}&page={$_GET['page']}" {if $_GET['fangshi']==''}class="ucurent"{/if}>全部</a></span>&nbsp;&nbsp;&nbsp;
  81. {loop $fangshi_array $k $val}
  82. <span><a href="{APP_PATH}index.php?m=content&c=index&a=lists&catid={$catid}&paytype={$_GET['paytype']}&housetype={$_GET['housetype']}&fangshi={$k}&dingshi={$_GET['dingshi']}&page={$_GET['page']}" {if $_GET['fangshi']==$k}class="ucurent"{/if}>{$val}</a></span>&nbsp;&nbsp;&nbsp;
  83. {/loop}
  84. </div>
  85. <div class="udiv"><strong>支付方式</strong>:
  86. <span><a href="{APP_PATH}index.php?m=content&c=index&a=lists&catid={$catid}&paytype=&housetype={$_GET['housetype']}&fangshi={$_GET['fangshi']}&dingshi={$_GET['dingshi']}&page={$_GET['page']}" {if $_GET['paytype']==''}class="ucurent"{/if}>全部</a></span>&nbsp;&nbsp;&nbsp;
  87. {loop $paytype_array $k $val}
  88. <span><a href="{APP_PATH}index.php?m=content&c=index&a=lists&catid={$catid}&paytype={$k}&housetype={$_GET['housetype']}&fangshi={$_GET['fangshi']}&dingshi={$_GET['dingshi']}&page={$_GET['page']}" {if $_GET['paytype']==$k}class="ucurent"{/if}>{$val}</a></span>&nbsp;&nbsp;&nbsp;
  89. {/loop}
  90. </div>
  91. <div class="udiv"><strong>房屋类型</strong>:
  92. <span><a href="{APP_PATH}index.php?m=content&c=index&a=lists&catid={$catid}&paytype={$_GET['paytype']}&housetype=&fangshi={$_GET['fangshi']}&dingshi={$_GET['dingshi']}&page={$_GET['page']}" {if $_GET['housetype']==''}class="ucurent"{/if}>全部</a></span>&nbsp;&nbsp;&nbsp;
  93. {loop $housetype_array $k $val}
  94. <span><a href="{APP_PATH}index.php?m=content&c=index&a=lists&catid={$catid}&paytype={$_GET['paytype']}&housetype={$k}&fangshi={$_GET['fangshi']}&dingshi={$_GET['dingshi']}&page={$_GET['page']}" {if $_GET['housetype']==$k}class="ucurent"{/if}>{$val}</a></span>&nbsp;&nbsp;&nbsp;
  95. {/loop}
  96. </div>
  97. <div class="udiv"><strong>厅室</strong>:
  98. <span><a href="{APP_PATH}index.php?m=content&c=index&a=lists&catid={$catid}&paytype={$_GET['paytype']}&housetype={$_GET['housetype']}&fangshi={$_GET['fangshi']}&dingshi=&page={$_GET['page']}" {if $_GET['dingshi']==''}class="ucurent"{/if}>全部</a></span>&nbsp;&nbsp;&nbsp;
  99. {loop $dingshi_array $k $val}
  100. <span><a href="{APP_PATH}index.php?m=content&c=index&a=lists&catid={$catid}&paytype={$_GET['paytype']}&housetype={$k}&fangshi={$_GET['fangshi']}&dingshi={$k}&page={$_GET['page']}" {if $_GET['dingshi']==$k}class="ucurent"{/if}>{$val}</a></span>&nbsp;&nbsp;&nbsp;
  101. {/loop}
  102. </div>
  103. <br /><br />
  104. {pc:content  action="lists" catid="$catid" where="$where" order="listorder DESC" thumb="1" num="12" return="data" page="$_GET['page']"}
  105. <ul class="photo-list picbig">
  106. {loop $data $r}
  107. <li>
  108. <div class="img-wrap">
  109. <a href="{$r[url]}"><img src="{thumb($r[thumb],150,112)}" width="150" height="112" alt="{$r[title]}"/></a>
  110. </div>
  111. <span style="color:{$r[style]}">{str_cut($r[title],28)}</span>
  112. </li>
  113. {/loop}
  114. </ul>
  115. <div id="pages" class="text-c">{$pages}</div>
  116. {/pc}
  117. </div>
  118. </div>
  119. {template "content","footer"}
PHPCMS数据筛选功能实现

PHPCMS数据筛选功能实现

转自织梦模板网,http://www.bbscms.net

相关文章