多选效果如下图:具体操作说明:一、注意,首先备份以下两个文件\include\arc.listview.class.php\include\extend.func.php多选版文件下载链接:https
多选效果如下图:
具体操作说明:
1、注意,首先备份以下两个文件
\include\arc.listview.class.php
\include\extend.func.php
2、修改extend.func.php文件,在其最后面添加如下代码:
//dedecms联动筛选功能 By 织梦技术研究中心 技术支持群:217479292 字符过滤函数
function wwwcms_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);
} else if ($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 |\r\n|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;
}
/**
* 载入自定义表单(用于发布)
*
* @access public
* @param string $fieldset 字段列表
* @param string $loadtype 载入类型
* @return string
*/
function AddFilter($channelid, $type=1, $fieldsnamef, $defaulttid, $loadtype='autofield')
{
global $tid,$dsql,$id;
$tid = $defaulttid ? $defaulttid : $tid;
if ($id!="")
{
$tidsq = $dsql->GetOne(" Select typeid From `#【分隔符】@__archives` where id='$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 `#【分隔符】@__channeltype` where id='$channelid' ");
$fieldset=$cInfos['fieldset'];
$dtp = new DedeTagParse();
$dtp->SetNameSpace('field','<','>');
$dtp->LoadSource($fieldset);
$dede_addonfields = '';
if(is_array($dtp->CTags))
{
foreach($dtp->CTags as $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 .= ''.$ctag->GetAtt('itemname').':';
switch ($type) {
case 1:
$dede_addonfields .= (preg_match("/&".$ctag->GetName()."=/is",$filterarr,$regm) ? 'GetName()."=".$fields_value,"",$filterarr).'">全部' : '全部').' ';
$addonfields_items = explode(",",$ctag->GetAtt('default'));
for ($i=0; $iGetName().'=') ? 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]) ? ''.$addonfields_items[$i].'' : ''.$addonfields_items[$i].'')." ";
}
$dede_addonfields .= ' ';
break;
case 2:
$dede_addonfields .= '
';
break;
}
}
}
}
echo $dede_addonfields;
}
多选版文件下载链接:https://pan.baidu.com/s/1eH92zuShdD3MfczlHGREKw
二、开始
1.把这些文件夹全部覆盖到根目录;
2.后台 - 系统 - 系统设置 - 系统基本参数 - 其他选项 - 禁用模板标签 ,把php删除后保存。
3.后台 - 核心 - 频道模型 - 内容模型管理
找到您要设置筛选的模型,这里以“普通文章”为例,点击右边的编辑按钮,在出来的页面中切换到“字段管理”,
点击“添加新字段”,填写的时候注意"数据类型"选择【Checkbox多选框】
三、模板调用说明
在需要显示筛选的地方加入
{dede:php}AddFilter(模型ID,类型,"字段1");{/dede:php}
例:
{dede:php}AddFilter(1,1,"area");{/dede:php}
模型ID
后台 - 核心 - 频道模型 - 内容模型管理
类型
1文字
2下拉
3单选
如果要指定使用哪些自定义参数,请使用
{dede:php}AddFilter(模型ID,类型,"字段1,字段1,字段1");{/dede:php}
例
{dede:php}AddFilter(1,1,"area,type,time,status");{/dede:php}
"area,type,time,status" 是指定的字段名,多个字段用半角逗号分隔。
首页调用方法
{dede:php}AddFilter(模型ID,类型,"字段1",栏目id);{/dede:php}
内容页调用方法
{dede:php}AddFilter(模型ID,类型,"字段1",栏目id,1);{/dede:php}