首页 > 运营 > 帮助中心 > 正文

phpcms V9二次开发之联动菜单筛选 包括box字段的多选 单选(含视频)

2019-10-17 22:31:12
字体:
来源:转载
供稿:网友
网上很多朋友需要PHPCMSv9的筛选模块,cms模板网今天分享给大家研究一下。
顺便分享此教程的视频教程


模型前台演示图
phpcms V9二次开发之联动菜单筛选 包括box字段的多选 单选(含视频)

文章筛选演示图
phpcms V9二次开发之联动菜单筛选 包括box字段的多选 单选(含视频)


一下是代码部分
----------------------------------------------------------------------------------------------------------------------------------------

<!--初始化init-->
{php $theurl = "index.php?m=content&c=index&a=lists&catid=$catid";}  <!-- 这是url的起始地址 -->
{php $brandid = (isset($_GET['brandid']) && is_numeric($_GET['brandid']) ? $_GET['brandid'] : '');}  <!-- url选项参数id处理 -->
{php $priceid = (isset($_GET['priceid']) && is_numeric($_GET['priceid']) ? $_GET['priceid'] : '');} <!-- url选项参数id处理 -->
{php $areaid = (isset($_GET['areaid']) && is_numeric($_GET['areaid']) ? $_GET['areaid'] : '');} <!-- url选项参数id处理 -->
{php $degree = (isset($_GET['degree']) ? $_GET['degree'] : '');} <!-- url选项参数id处理 -->


<!-- 读取缓存-->
{php $modelid_cache = getcache('model_field_'.$modelid,'model');} <!-- 模型缓存 说明 :  当前模型所有的字段缓存 -->
{php $brand_linkage = getcache(3360,'linkage'); $brand_data = $brand_linkage[data];} <!-- 品牌缓存 说明:品牌的缓存ID读取 -->
{php $area_linkage = getcache(3379,'linkage'); $area_data = $area_linkage[data];} <!-- 区域缓存 说明:区域的缓存ID读取-->

<!-- sql_条件-->
<?php
/**** 区域选项id处理开始 ****/
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;
}
}
/**** 区域选项id处理结束 ****/

/**-- 排序的数组 --**/
$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();}

价格 :

{if $priceid}
全部
{else}
全部
{/if}


{loop $data $r}
{php $r = explode("|",trim($r))}
{php $price_arr[$r[1]] = $r[0];}
{if $priceid == $r[1]}
{$r[0]}
{else}
{$r[0]}
{/if}
{/loop}

{php $data = explode("/r/n", $modelid_cache['degree']['options']);}

学历 :

{if $degree}
全部
{else}
全部
{/if}

{loop $data $r}
{php $r = explode("|",trim($r))}
{if $degree == $r[1]}
{$r[0]}
{else}
{$r[0]}
{/if}
{/loop}

品牌 :
{if $brandid}
全部
{else}
全部
{/if}
{loop $brand_data $r}
{if $brandid == $r[linkageid]}
{$r[name]}
{else}
{$r[name]}
{/if}
{/loop}

商圈 :
{if $_GET[areaid]}
全部
{else}
全部
{/if}
{loop $boroughs $key $val}
{if $_GET[areaid] == $key || $paid == $key}
{$val}
{else}
{$val}
{/if}
{/loop}

{if $_GET[areaid]}

{loop $streets $key $val}
{if $_GET[areaid] == $key}
{$val}
{else}
{$val}
{/if}
{/loop}


{/if}

{pc:get sql="SELECT * FROM v9_news WHERE $wheresql" cache="3600" num="10" page="$page" return="data"}

共找到 {php echo count($data);} 个结果

{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));}


{date('Y-m-d H:i:s',$r[inputtime])}·{$r[title]}

学历要求:{$r[degree]}

价格区间:[{$price_arr[$r[priceid]]}] 品牌:[{$brand_data[$r[brandid]][name]}] 区域:[{$area_data[$r[areaid]][name]}] 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}

{if $n%5==0}
{/if}
{/loop}

{$pages}

{/pc}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表