这种多条件筛选构思上就是利用条件拼接sql语句,但就dedecms的功能来看,静态页比较难实现。建议进行二次开发,或者制作php单页。
况且存储你所要查询的信息的表,应该也不是dede内置的表就能做的。
一个比较好的方式就是静态的栏目页,用ajax向一个php页提交参数,得到返回值后载入到页面中,体验好,难度也不大。
引入 /include/common.inc.php 文件,利用dedecms的语法二次开发吧
第一步打开include文件夹下的extend.func.php文件
/*dedecms联动筛选功能字符过滤函数*/
functionwwwcms_filter($str,$stype="inject"){
if($stype=="inject"){
$str=str_replace(array("select","insert","update","delete","alter","cas","union","into","load_file","outfile","create","join","where","like","drop","modify","rename","‘","/*","*","../","./"),array("","","","","","","","","","","","","","","","","","","","","",""),$str);
}
elseif($stype=="xss"){
$farr=array("/s+/","/<(/?)(script|META|STYLE|HTML|HEAD|BODY|STYLE|i?frame|b|strong|style|html|img|P|o:p|iframe|u|em|strike|BR|div|a|TABLE|TBODY|object|tr|td|st1:chsdate|FONT|span|MARQUEE|body|title||link|meta|?|/%)([^>]*?)>/isU","/(<[^>]*)on[a-zA-Z]+s*=([^>]*>)/isU",);
$tarr=array("","","/1/2",);
$str=preg_replace($farr,$tarr,$str);
$str=str_replace(array("<",">","‘",""",";","/*","*","../","./"),array("<",">","","","","","","",""),$str);
}
return$str;
}
/**
*载入自定义表单(用于发布)
*
*@accesspublic
*@paramstring$fieldset字段列表
*@paramstring$loadtype载入类型
*@returnstring
*/
functionAddFilter($channelid,$type=1,$fieldsnamef,$defaulttid,$loadtype='autofield'){
global$tid,$dsql,$id;
$tid=$defaulttid?$defaulttid:$tid;
if($id!=""){
$tidsq=$dsql->GetOne("SelecttypeidFrom`dede_archives`whereid='$id'");
$tid=$tidsq["typeid"];
}
$nofilter=(isset($_REQUEST['TotalResult'])?"&TotalResult=".$_REQUEST['TotalResult']:'').(isset($_REQUEST['PageNo'])?"&PageNo=".$_REQUEST['PageNo']:'');
$filterarr=wwwcms_filter(stripos($_SERVER['REQUEST_URI'],"list.php?tid=")?str_replace($nofilter,'',$_SERVER['REQUEST_URI']):$GLOBALS['cfg_cmsurl']."/plus/list.php?tid=".$tid);
$cInfos=$dsql->GetOne("Select*From`dede_channeltype`whereid='$channelid'");
$fieldset=$cInfos['fieldset'];
$dtp=newDedeTagParse();
$dtp->SetNameSpace('field','<','>');
$dtp->LoadSource($fieldset);
$dede_addonfields='';
if(is_array($dtp->CTags)){
foreach($dtp->CTagsas$tid=>$ctag){
$fieldsname=$fieldsnamef?explode(",",$fieldsnamef):explode(",",$ctag->GetName());
if(($loadtype!='autofield'||($loadtype=='autofield'&&$ctag->GetAtt('autofield')==1))&&in_array($ctag->GetName(),$fieldsname)){
$href1=explode($ctag->GetName().'=',$filterarr);
$href2=explode('&',$href1[1]);
$fields_value=$href2[0];
$dede_addonfields.='<divclass="scv-shaixuan"><b>'.$ctag->GetAtt('itemname').':</b>';
switch($type){
case1:
$dede_addonfields.=(preg_match("/&".$ctag->GetName()."=/is",$filterarr,$regm)?'<atitle="全部"href="'.str_replace("&".$ctag->GetName()."=".$fields_value,"",$filterarr).'">全部</a>':'<span>全部</span>').' ';
$addonfields_items=explode(",",$ctag->GetAtt('default'));
for($i=0;$i<count($addonfields_items);$i++){
$href=stripos($filterarr,$ctag->GetName().'=')?str_replace("=".$fields_value,"=".urlencode($addonfields_items[$i]),$filterarr):$filterarr.'&'.$ctag->GetName().'='.urlencode($addonfields_items[$i]);//echo$href;
$dede_addonfields.=($fields_value!=urlencode($addonfields_items[$i])?'<atitle="'.$addonfields_items[$i].'"href="'.$href.'">'.$addonfields_items[$i].'</a>':'<span>'.$addonfields_items[$i].'</span>')." ";
}
$dede_addonfields.='</div>';
break;
case2:
$dede_addonfields.='<selectname="filter"'.$ctag->GetName().'onchange="window.location=this.options[this.selectedIndex].value">
'.'<optionvalue="'.str_replace("&".$ctag->GetName()."=".$fields_value,"",$filterarr).'">全部</option>';
$addonfields_items=explode(",",$ctag->GetAtt('default'));
for($i=0;$i<count($addonfields_items);$i++){
$href=stripos($filterarr,$ctag->GetName().'=')?str_replace("=".$fields_value,"=".urlencode($addonfields_items[$i]),$filterarr):$filterarr.'&'.$ctag->GetName().'='.urlencode($addonfields_items[$i]);
$dede_addonfields.='<optionvalue="'.$href.'"'.($fields_value==urlencode($addonfields_items[$i])?'selected="selected"':"").'>'.$addonfields_items[$i].'</option>';
}
$dede_addonfields.='</select><br/>';
break;
}
}
}
}
echo$dede_addonfields;
}
//联动筛选Over
新闻热点
疑难解答