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

phpcmsv9联动菜单实现筛选代码示例

春翠2025-06-12phpcms教程已有人查阅

导读{php $theurl = "index.php?m=content&c=index&a=lists&catid=$catid";}

<!--初始化init-->
{php $theurl = "index.php?m=content&c=index&a=lists&catid=$catid";}
{php $brandid = (isset($_get['brandid']) && is_numeric($_get['brandid']) ? $_get['brandid'] : '');}
{php $priceid = (isset($_get['priceid']) && is_numeric($_get['priceid']) ? $_get['priceid'] : '');}
{php $areaid = (isset($_get['areaid']) && is_numeric($_get['areaid']) ? $_get['areaid'] : '');}
{php $degree = (isset($_get['degree']) ? $_get['degree'] : '');}
<!-- 读取缓存-->
{php $modelid_cache = getcache('model_field_'.$modelid,'model');} <!-- 模型缓存 -->
{php $brand_linkage = getcache(3360,'linkage'); $brand_data = $brand_linkage[data];}<!-- 品牌缓存 -->
{php $area_linkage = getcache(3379,'linkage'); $area_data = $area_linkage[data];} <!-- 区域缓存 -->
<!-- sql_条件-->
<?php
if($area_data[$_get[areaid]][parentid] == 0) {
$paid = 0;
} else {
$paid = $area_data[$_get[areaid]]['parentid'];
}
$areaid_arr = array();
$boroughs = $streets = '';
foreach($area_data as $k=>$r){
if($r[parentid] == 0){
$boroughs[$k]= $r['name'];
}elseif(($_get[areaid] == $r['parentid'] || $paid == $r['parentid'])){
$streets[$k]= $r['name'];
$areaid_arr[] = $k;
}
}
/**-- 排序的数组 --**/
$order_arr= array(
'finer' => array('finer'=>'desc'),
'avgsort' => array('avgsort'=>'desc'),
'reviews' => array('reviews'=>'desc'),
'enjoy' => array('enjoy'=>'desc'),
'price' => array('avgprice'=>'desc'),
'price_s' => array('avgprice'=>'asc'),
'picture' => array('pictures'=>'desc'),
'picture_s' => array('pictures'=>'asc'),
'addtime' => array('addtime'=>'desc'),
'pageviews' => array('pageviews'=>'desc'),
);
/**-- 查询的数组 --**/
$where = array();
if($catid) $where['catid'] = (int) $catid;
if($brandid) $where['brandid'] = (int) $brandid;
if($priceid) $where['priceid'] = (int) $priceid;
if($paid){
if($areaid) $where['areaid'] = (int) $areaid;
$areasql = '';
}else{
if($areaid) $areasql = ' and `areaid` in('.join(',',$areaid_arr).')';
}
function getwheresql($wheresqlarr) {
$result = $comma = '';
if(empty($wheresqlarr)) {
$result = '1';
} elseif(is_array($wheresqlarr)) {
foreach ($wheresqlarr as $key => $value) {
$result .= $comma.$key.'=\''.$value.'\'';
$comma = ' and ';
}
} else {
$result = $wheresqlarr;
}
return $result;
}
$wheresql = getwheresql($where);
$wheresql .= $areasql;
//echo $wheresql;
?>
{php $data = explode("\r\n", $modelid_cache['priceid']['options']);}
{php $price_arr = array();}
<div class="col-cate">
<b>价格 :</b>
{if $priceid}
<a href="{url_par("brandid=$brandid&areaid=$areaid",$theurl)}" style="color:#6633ff;">全部</a>
{else}
<font style="color:#fff; background-color:#6633ff">全部</font>
{/if}
{loop $data $r}
{php $r = explode("|",trim($r))}
{php $price_arr[$r[1]] = $r[0];}
{if $priceid == $r[1]}
<font style="color:#fff; background-color:#6633ff">{$r[0]}</font>
{else}
<a href='{url_par("brandid=$brandid&priceid=$r[1]&areaid=$areaid",$theurl)}'>{$r[0]}</a>
{/if}
{/loop}
</div>
{php $data = explode("\r\n", $modelid_cache['degree']['options']);}
<div class="col-cate">
<b>学历 :</b>
{if $degree}
<a href="{url_par("brandid=$brandid&priceid=$priceid&areaid=$areaid",$theurl)}" style="color:#6633ff;">全部</a>
{else}
<font style="color:#fff; background-color:#6633ff">全部</font>
{/if}
{loop $data $r}
{php $r = explode("|",trim($r))}
{if $degree == $r[1]}
<font style="color:#fff; background-color:#6633ff">{$r[0]}</font>
{else}
<a href='{url_par("brandid=$brandid&priceid=$priceid°ree=$r[1]&areaid=$areaid",$theurl)}'>{$r[0]}</a>
{/if}
{/loop}
</div>
<div class="col-cate">
<b>品牌 :</b>
{if $brandid}
<a href="{url_par("priceid=$priceid&areaid=$areaid",$theurl)}" style="color:#6633ff;">全部</a>
{else}
<font style="color:#fff; background-color:#6633ff">全部</font>
{/if}
{loop $brand_data $r}
{if $brandid == $r[linkageid]}
<font style="color:#fff; background-color:#6633ff">{$r[name]}</font>
{else}
<a href="{url_par("brandid=$r[linkageid]&priceid=$priceid&areaid=$areaid",$theurl)}">{$r[name]}</a>
{/if}
{/loop}
</div>
<div class="col-cate">
<b>商圈 :</b>
{if $_get[areaid]}
<a href="{url_par("brandid=$brandid&priceid=$priceid",$theurl)}" style="color:#6633ff;">全部</a>
{else}
<font style="color:#fff; background-color:#6633ff">全部</font>
{/if}
{loop $boroughs $key $val}
{if $_get[areaid] == $key || $paid == $key}
<font style="color:#fff; background-color:#6633ff"> {$val}</font>
{else}
<a href="{url_par("brandid=$brandid&priceid=$priceid&areaid=$key",$theurl)}">{$val}</a>
{/if}
{/loop}
</div>
{if $_get[areaid]}
<div class="col_cate_2" style="padding:8px; border:1px solid #57a3c9; background-color:#eff5f8; margin-top:4px;">
{loop $streets $key $val}
{if $_get[areaid] == $key}
<font style="color:#fff; background-color:#6633ff"> {$val}</font>
{else}
<a href="{url_par("brandid=$brandid&priceid=$priceid&areaid=$key",$theurl)}">{$val}</a>
{/if}
{/loop}
</div>
{/if}
{pc:get sql="select * from v9_news where $wheresql" cache="3600" num="10" page="$page" return="data"}
<h3 style="font-size:12px; color:#ff0000; line-height:22px; text-align:right;">共找到 {php echo count($data);} 个结果</h3>
<ul class="list lh24 f14" style="margin-top:12px;">
{loop $data $r}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));}
<li style="background-color:#f9f9f9; border-bottom:1px solid #999999; margin-top:4px;"><span class="rt">{date('y-m-d h:i:s',$r[inputtime])}</span>·<a href="{$r[url]}" target="_blank"{title_style($r[style])}>{$r[title]}</a>
<p><span style="font-size:11px; font-family:pmingliu; color:#666666;">学历要求:{$r[degree]}</span></p>
<p><span style="font-size:11px; font-family:pmingliu; color:#666666;">价格区间:<font style="font-family:verdana, arial, helvetica, sans-serif; font-size:10px;">[{$price_arr[$r[priceid]]}]</font> 品牌:<span {if $r[brandid] == $brandid} style="color:#f00;"{/if}>[{$brand_data[$r[brandid]][name]}] </span>区域:[{$area_data[$r[areaid]][name]}] 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</span></p>
</li>
{if $n%5==0}<li class="bk20 hr"></li>{/if}
{/loop}
</ul>
<div id="pages" class="text-c">{$pages}</div>
{/pc}

本文标签:

很赞哦! ()

相关源码

  • (PC+WAP)房屋建造建筑工程房地产建材行pbootcms网站模板下载本模板基于PbootCMS内核开发,为房屋建造、建筑工程及房地产建材类企业设计。通过本模板可快速搭建具有行业特色的企业官网,只需替换文字与图片内容即可适配其他行业使用。查看源码
  • (PC+手机)帝国cms7.5漫画图片连载网站源码免费下载本模板基于帝国CMS7.5深度开发,为漫画阅读类网站打造。整体设计风格贴合漫画行业特性,界面布局充分考虑漫画作品的展示需求,支持多种漫画阅读模式。模板采用响应式设计,能够自动适配PC端和移动端设备,为读者提供流畅的阅读体验。查看源码
  • 响应式艺考培训学校机构pbootcms模板html5源码基于PbootCMS免费开源内核开发,为艺考培训学校与艺术机构设计,替换图文即可快速适配全行业需求。响应式布局兼容手机/PC端,数据实时同步,运维效率提升300%。查看源码
  • (自适应响应式)宠物经验资讯咨询博客pbootcms网站源码下载除宠物资讯领域外,通过内容替换可快速适配宠物用品商城、宠物医疗咨询平台、宠物训练教程网站、动物保护组织官网、水族爱好者社区等垂直领域。查看源码
  • (PC+WAP)绿色硅胶橡胶玩具制品营销型网站源码下载为硅胶橡胶制品及玩具行业打造的营销型网站模板,采用PbootCMS内核开发,通过模块化设计实现产品参数、安全认证、应用场景等专业内容的可视化呈现,助力企业建立可信赖的线上展示平台。查看源码
  • 帝国cms7.5个人博客资讯文章模板下载本模板简洁个人博客网站设计开发,采用帝国CMS内核构建,只需替换文字图片即可快速搭建专业网站。自适应手机端设计,数据实时同步,操作简单便捷。PHP程序确保安全稳定运行,帮助您以较低成本获取持续业务。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐