把下面的代碼復制到 e/class/userfun.php 里面
然后把對應的文字改成自己的就可以!
function user_Showfenlei($ecms=0){global $public_r,$navclassid;//------- 函數參數設置開始 -----//要顯示的結合項字段列表,多個字段用半角逗號“,”隔開$fieldandvar='myarea,sex,age';//字段顯示選項設置,多項用雙“#”號隔開,格式:選項說明|==|內容1,值1##內容2,值2$fieldandval=array();$fieldandval['myarea']='<b>地區:</b>|==|不限,##東城,東城區##朝陽,朝陽區##崇文,崇文區##宣武,宣武區##海淀,海淀區##豐臺,豐臺區';$fieldandval['sex']='<b>性別:</b>|==|不限,##男,男##女,女##人妖,人妖';$fieldandval['age']='<b>年齡:</b>|==|不限,##1-10,1__10##11-20,11__20##21-30,21__30##31-40,31__40##41-50,41__50##50歲以上,51__200';//正常鏈接樣式$fieldandcss='fieldandcss';//已選的選項鏈接樣式$changefieldandcss='changefieldandcss';//字段與字段的顯示間隔符,格式:開始顯示字符|結束顯示字符$fieldexp='<table><tr><td>|</td></tr></table>';//選項與選項的顯示間隔符,格式:開始顯示字符|結束顯示字符$valexp='| ';//------- 函數參數設置結束 -----//附加參數$urlcs='';$mid=(int)$_GET['mid'];if($mid){$urlcs.='&mid='.$mid;}if($_GET['classid']) { $classid=RepPostVar($_GET['classid']); $urlcs.='&classid='.$classid; } else { $urlcs.='&classid='.$navclassid; }if($_GET['ttid']){$ttid=RepPostVar($_GET['ttid']);$urlcs.='&ttid='.$ttid;}if($_GET['ztid']){$ztid=RepPostVar($_GET['ztid']);$urlcs.='&ztid='.$ztid;}if($_GET['endtime']){$starttime=RepPostVar($_GET['starttime']);$endtime=RepPostVar($_GET['endtime']);$urlcs.='&starttime='.$starttime.'&endtime='.$endtime;}$line=(int)$_GET['line'];if($line){$urlcs.='&line='.$line;}$tempid=(int)$_GET['tempid'];if($tempid){$urlcs.='&tempid='.$tempid;}if($_GET['orderby']){$orderby=RepPostVar($_GET['orderby']);$myorder=(int)$_GET['myorder'];$urlcs.='&orderby='.$orderby.'&myorder='.$myorder;}//間隔字符$fieldexpr=explode('|',$fieldexp);$valexpr=explode('|',$valexp);//輸出選項$fr=explode(',',$fieldandvar);$fcount=count($fr);$allstr='';$urladd='';for($i=0;$i<$fcount;$i++){$field=$fr[$i];//選項鏈接$getval='';if($_GET[$field]){$getval=htmlspecialchars($_GET[$field],ENT_QUOTES);$urladd.='&'.$field.'='.urlencode($getval);}//選項說明$vsayr=explode('|==|',$fieldandval[$field]);//選項內容$valallstr='';$vr=explode('##',$vsayr[1]);$vcount=count($vr);for($vi=0;$vi<$vcount;$vi++){$vtr=explode(',',$vr[$vi]);if($getval==$vtr[1]){$css=$changefieldandcss;}else{$css=$fieldandcss;}$valallstr.=$valexpr[0].'<a href="'.$public_r['newsurl'].'e/action/ListInfo.php?'.$urlcs.'&ph=1<!--url.add-->&'.$field.'='.urlencode($vtr[1]).'" class="'.$css.'">'.$vtr[0].'</a>'.$valexpr[1];}$allstr.=$fieldexpr[0].$vsayr[0].$valallstr.$fieldexpr[1];}$allstr=str_replace('<!--url.add-->',$urladd,$allstr);preg_match_all ('/<a href=/"(.*?)/".*?>(.*?)<//a>/i',$allstr,$matches); for($i=0;$i<count($matches[1]);$i++){ $url = $matches[1][$i]; $parts = parse_url($url); $query = explode('&', $parts[query]); $output=array(); foreach ($query as $key => $value) { if($value){ $params = explode('=', $value); if($params[0]){ $output[$params[0]]=urldecode($params[1]); } } } $newurl = $parts[path].'?'.http_build_query($output); $allstr = str_replace('href="'.$url.'"', 'href="'.$newurl.'"', $allstr);}echo $allstr;}
在列表也用 <?=user_Showfenlei();?> 調用!
如果需要顯示結果 并且可取消 在
echo $allstr;
后面加上:
foreach ($_GET as $key=>$val){
if($val && in_array($key, $fr)){
$url_this=$key.'='.urlencode($val);
$url=str_replace($url_this,'',$_SERVER[REQUEST_URI]);
$tj='已選擇條件:';
$yixuan.='<a class="del_jhx" href="'.$url.'">'.$val.'x</a> ';
}
}
echo $tj.$yixuan;
CSS樣式:
.fieldandcss{}
.changefieldandcss{background:#4598D2;color:#fff;}
.del_jhx{ border:1px solid #0CF; padding:2px;}
新聞熱點
疑難解答