今天在做一个织梦dedecms 企业网站的时候,需要用到分类信息,织梦模板是用的DEDECMS V5.7版本的,在修改联动类别里面的信息类型的时候发现只能增加一级选择和三级选择,就是不能增加二级选择,怎么办呢?
去织梦官方找了下解决办法没得,看来只能自己研究了。
后来使用DEDECMSV5.6版本的进行测试,发现5.6的是可以使用的,那就可以找到解决的办法了。
首先我们找到我们的模板源码下面的 dede/stepselect_main.php 这个文件,
将这段代码
else if($action=='addenum_save')
{
if(empty($ename) || empty($egroup))
{
Showmsg("类别名称或组名称不能为空!","-1");
exit();
}
if($issign == 1 || $topvalue == 0)
{
$enames = explode(',', $ename);
foreach($enames as $ename)
{
$arr = $dsql->GetOne("SELECT * FROM `dede_sys_enum` WHERE egroup='$egroup' AND (evalue MOD 500)=0 ORDER BY disorder DESC ");
if(!is_array($arr)) $disorder = $evalue = ($issign==1 ? 1 : 500);
else $disorder = $evalue = $arr['disorder'] + ($issign==1 ? 1 : 500);
$dsql->ExecuteNoneQuery("INSERT INTO `dede_sys_enum`(`ename`,`evalue`,`egroup`,`disorder`,`issign`)
VALUES('$ename','$evalue','$egroup','$disorder','$issign'); ");
}
WriteEnumsCache($egroup);
ShowMsg("成功添加枚举分类!".$dsql->GetError(), $ENV_GOBACK_URL);
exit();
} else if ($issign == 2 && $topvalue != 0)
{
$minid = $topvalue;
$maxnum = 500; // 三级子类最多500个
$enames = explode(',', $ename);
foreach ($enames as $ename)
{
$arr = $dsql->GetOne("SELECT * FROM `dede_sys_enum` WHERE egroup='$egroup' AND evalue LIKE '$topvalue.%%%' ORDER BY evalue DESC ");
if(!is_array($arr))
{
$disorder = $minid;
$evalue = $minid.'.001';
}
else
{
$disorder = $minid;
preg_match("#([0-9]{1,})\.([0-9]{1,})#", $arr['evalue'], $matchs);
$addvalue = $matchs[2] + 1;
$addvalue = sprintf("%03d", $addvalue);
$evalue = $matchs[1].'.'.$addvalue;
}
$sql = "INSERT INTO `dede_sys_enum`(`ename`,`evalue`,`egroup`,`disorder`,`issign`)
VALUES('$ename','$evalue','$egroup','$disorder','$issign'); ";
// echo $sql;exit;
$dsql->ExecuteNoneQuery($sql);
}
// echo $minid;
WriteEnumsCache($egroup);
ShowMsg("成功添加枚举分类!", $ENV_GOBACK_URL);
exit();
} else {
$minid = $topvalue;
$maxid = $topvalue + 500;
$enames = explode(',', $ename);
foreach($enames as $ename)
{
$arr = $dsql->GetOne("SELECT * FROM `dede_sys_enum` WHERE egroup='$egroup' AND evalue>$minid AND evalue<$maxid ORDER BY evalue DESC ");
if(!is_array($arr))
{
$disorder = $evalue = $minid+1;
}
else
{
$disorder = $arr['disorder']+1;
$evalue = $arr['evalue']+1;
}
$dsql->ExecuteNoneQuery("INSERT INTO `dede_sys_enum`(`ename`,`evalue`,`egroup`,`disorder`,`issign`)
VALUES('$ename','$evalue','$egroup','$disorder','$issign'); ");
}
WriteEnumsCache($egroup);
ShowMsg("成功添加枚举分类!", $ENV_GOBACK_URL);
exit();
}
}
替换为:
else if($action=='addenum_save')
{
if(empty($ename) || empty($egroup)) {
Showmsg("类别名称或组名称不能为空!","-1");
exit();
}
if($issign==1 || $topvalue==0)
{
$enames = explode(',', $ename);
foreach($enames as $ename)
{
$arr = $dsql->GetOne("Select * From `dede_sys_enum` where egroup='$egroup' And (evalue mod 500)=0 order by evalue desc ");
if(!is_array($arr)) $disorder = $evalue = ($issign==1 ? 1 : 500);
else $disorder = $evalue = $arr['disorder'] + ($issign==1 ? 1 : 500);
$dsql->ExecuteNoneQuery("Insert into `dede_sys_enum`(`ename`,`evalue`,`egroup`,`disorder`,`issign`)
values('$ename','$evalue','$egroup','$disorder','$issign'); ");
}
WriteEnumsCache($egroup);
ShowMsg("成功添加枚举分类!".$dsql->GetError(), $ENV_GOBACK_URL);
exit();
}
else
{
$minid = $topvalue;
$maxid = $topvalue + 500;
$enames = explode(',', $ename);
foreach($enames as $ename)
{
$arr = $dsql->GetOne("Select * From `dede_sys_enum` where egroup='$egroup' And evalue>$minid And evalue<$maxid order by evalue desc ");
if(!is_array($arr))
{
$disorder = $evalue = $minid+1;
}
else
{
$disorder = $arr['disorder']+1;
$evalue = $arr['evalue']+1;
}
$dsql->ExecuteNoneQuery("Insert into `dede_sys_enum`(`ename`,`evalue`,`egroup`,`disorder`,`issign`)
values('$ename','$evalue','$egroup','$disorder','$issign'); ");
}
WriteEnumsCache($egroup);
ShowMsg("成功添加枚举分类!", $ENV_GOBACK_URL);
exit();
}
}
然后保存,在系统后台更新系统缓存就可以了的。现在在后台的联动类别管理里面就可以增加二级选择了。
(责任编辑:最模板) |