您现在的位置是:首页 > cms教程 > phpcms教程phpcms教程

PHPCMS数据筛选功能实现方法代码示例

涂翰毅2025-05-21phpcms教程已有人查阅

导读第一步:添加模型字段,这个模型可以是官方的,也可以是你自定义的模型,以单选字段形式添加就好了;第二步:就是添加栏目和内容;第三步:模板如下,照着改就好了。

第一步:添加模型字段,这个模型可以是官方的,也可以是你自定义的模型,以单选字段形式添加就好了;
第二步:就是添加栏目和内容;
第三步:模板如下,照着改就好了。
{template "content","header"}
<!-- 开始取出字段--------------------------------------------- -->
{pc:get sql="SELECT * FROM `v9_model_field` where `field`='fangshi' and `modelid`='3'" return="data"}
<?php
$optionsn='';
eval("\$setting_arr =".$data[0]['setting'].";");
$optionsn=explode("\n",$setting_arr['options']);
$fangshi_array=array(); //修改这个地方
foreach( $optionsn as $kk=>$vv){
$optionsn_vv=explode("|",$vv);
$fangshi_array[trim($optionsn_vv[1])]=trim($optionsn_vv[0]); //修改这个地方
}
?>
{/pc}
{pc:get sql="SELECT * FROM `v9_model_field` where `field`='paytype' and `modelid`='3'" return="data"}
<?php
$optionsn='';
eval("\$setting_arr =".$data[0]['setting'].";");
$optionsn=explode("\n",$setting_arr['options']);
$paytype_array=array(); //修改这个地方
foreach( $optionsn as $kk=>$vv){
$optionsn_vv=explode("|",$vv);
$paytype_array[trim($optionsn_vv[1])]=trim($optionsn_vv[0]); //修改这个地方
}
?>
{/pc}
{pc:get sql="SELECT * FROM `v9_model_field` where `field`='housetype' and `modelid`='3'" return="data"}
<?php
$optionsn='';
eval("\$setting_arr =".$data[0]['setting'].";");
$optionsn=explode("\n",$setting_arr['options']);
$housetype_array=array(); //修改这个地方
foreach( $optionsn as $kk=>$vv){
$optionsn_vv=explode("|",$vv);
$housetype_array[trim($optionsn_vv[1])]=trim($optionsn_vv[0]); //修改这个地方
}
?>
{/pc}
{pc:get sql="SELECT * FROM `v9_model_field` where `field`='dingshi' and `modelid`='3'" return="data"}
<?php
$optionsn='';
eval("\$setting_arr =".$data[0]['setting'].";");
$optionsn=explode("\n",$setting_arr['options']);
$dingshi_array=array(); //修改这个地方
foreach( $optionsn as $kk=>$vv){
$optionsn_vv=explode("|",$vv);
$dingshi_array[trim($optionsn_vv[1])]=trim($optionsn_vv[0]); //修改这个地方
}
?>
{/pc}
<!-- 结束取出字段--------------------------------------------- -->
<!-- 开始拼装where -->
<?php
$where="";
if(!empty($_GET['fangshi'])){
$where.="`fangshi` = '".$_GET['fangshi']."' AND ";
}
if(!empty($_GET['paytype'])){
$where.="`paytype` = '".$_GET['paytype']."' AND ";
}
if(!empty($_GET['housetype'])){
$where.="`housetype` = '".$_GET['housetype']."' AND ";
}
if(!empty($_GET['dingshi'])){
$where.="`dingshi` = '".$_GET['dingshi']."' AND ";
}
$where.=1;
?>
<!-- 结束拼装where -->
<!--main-->
<div class="main photo-channel">
<div class="crumbs"><a href="{siteurl($siteid)}">首页</a><span> > {catpos($catid)}</div>
<div class="bk10"></div>
<style>
.udiv{ margin-bottom:10px;}
.ucurent{ background:#FF0; padding:2px; font-weight:bold;}
</style>
<div class="udiv"><strong>租房方式</strong>:
<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>
{loop $fangshi_array $k $val}
<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>
{/loop}
</div>
<div class="udiv"><strong>支付方式</strong>:
<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>
{loop $paytype_array $k $val}
<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>
{/loop}
</div>
<div class="udiv"><strong>房屋类型</strong>:
<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>
{loop $housetype_array $k $val}
<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>
{/loop}
</div>
<div class="udiv"><strong>厅室</strong>:
<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>
{loop $dingshi_array $k $val}
<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>
{/loop}
</div>
<br /><br />
{pc:content action="lists" catid="$catid" where="$where" order="listorder DESC" thumb="1" num="12" return="data" page="$_GET['page']"}
<ul class="photo-list picbig">
{loop $data $r}
<li>
<div class="img-wrap">
<a href="{$r[url]}"><img src="{thumb($r[thumb],150,112)}" width="150" height="112" alt="{$r[title]}"/></a>
</div>
<span style="color:{$r[style]}">{str_cut($r[title],28)}</span>
</li>
{/loop}
</ul>
<div id="pages" class="text-c">{$pages}</div>
{/pc}
</div>
</div>
{template "content","footer"}

本文标签:

很赞哦! ()

相关源码

  • (自适应响应式)双语LED照明灯饰灯具外贸网站pbootcms源码下载模板采用响应式设计,能自动适应手机、平板和电脑等多种设备屏幕,确保用户在不同设备上都能获得良好的浏览体验。同一后台管理,数据实时同步,操作简便高效。查看源码
  • (自适应)蓝色厨卫厨房水龙头阀门水槽设备源码下载基于PbootCMS内核开发,深度适配厨卫设备行业特性。通过精准的产品展示模块与水效标识专区设计,有效呈现五金件工艺细节。响应式布局确保从手机到平板都能展示金属质感与水流动态效果。查看源码
  • (自适应)驾校培训学车活动免费pbootcms源码下载本模板基于PbootCMS内核开发,为驾校培训行业打造,具备完善的招生展示、课程预约、教练团队展示等功能模块。响应式设计适配各类移动终端,数据实时同步管理,助您高效开展线上业务。查看源码
  • (PC+WAP)绿色日志美文文学说说博客网站pbootcms模板除日志博客类网站外,通过替换图文内容可快速适配:心情日记分享平台、文学创作社区、朋友圈内容聚合站、美文鉴赏网站、读书笔记平台等应用场景。查看源码
  • (PC+WAP)家居装饰家装建材营销型网站pbootcms模板下载本模板基于PbootCMS开发,主要服务于家居装饰、建材及相关行业。采用现代化设计风格,同时适配PC和移动设备访问。模板结构清晰,突出展示家装案例和建材产品,帮助企业在线上建立专业形象,有效展示产品与服务优势。查看源码
  • (PC+WAP)化工材料企业环保能源绿色营销型pbootcms模板源码下载本模板为化工材料及环保能源企业设计,采用PbootCMS开发,可展示各类化工产品、环保技术及能源解决方案。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐