您现在的位置是:首页 > 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"}

本文标签:

很赞哦! ()

相关源码

  • (自适应)WordPress二次元博客主题SakurairoSakurairo主题为二次元内容创作者设计,提供丰富的动漫风格元素和个性化的展示效果。该主题在原有Sakura主题基础上进行了功能增强,支持多种自定义设置,满足动漫爱好者建立个人博客的需求。查看源码
  • (PC+WAP)楼承板建筑工程合金钢铁材料pbootcms网站源码下载为楼承板生产商及建筑工程企业设计的响应式网站模板,采用PbootCMS内核开发,同步适配电脑与移动设备浏览。通过模块化结构展示工程案例、产品参数等专业内容,帮助建筑建材企业建立标准化数字展示平台,提升行业专业形象。查看源码
  • (自适应)居家生活日用品纸盘纸盒纸杯卫生纸巾生产厂家pbootcms模板为纸品生产企业打造的现代化展示平台,自动适应各种设备屏幕,确保浏览体验一致,完善的SEO功能,提升网站曝光度,基于PbootCMS构建,源码开放可定制。查看源码
  • 帝国cms7.5模板情感文学名言名句心情文章类源码下载带手机本模板基于帝国CMS7.5开发,为情感文学类网站设计。整体风格温馨雅致,布局合理清晰,特别适合建设情书分享、文学作品展示类网站。模板采用响应式设计,能够自动适配各种终端设备。查看源码
  • (自适应)驾校培训学车活动免费pbootcms源码下载本模板基于PbootCMS内核开发,为驾校培训行业打造,具备完善的招生展示、课程预约、教练团队展示等功能模块。响应式设计适配各类移动终端,数据实时同步管理,助您高效开展线上业务。查看源码
  • (PC+WAP)生活资讯百科新闻门户类pbootcms网站模板为生活资讯、百科门户类企业打造的高性能网站模板,基于PbootCMS开源内核开发,采用HTML5响应式架构,PC与手机端实时数据同步,覆盖全终端用户浏览场景。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐