让dedecms联动模型支持dede_sys_enum的father字段自动追加
对dede_sys_enum添加father字段,实现目的:在添加联动分类时,自动添加father的值。以500为分类界限。即:503的父类(father)为503,1001的father为1000。
主要修改的文件 stepselect_main.php文件。
解决: 修改有三处。
1.主要添加内容:
$father = intval(floor($evalue/500))*500;
2.修改内容:
$sql = "INSERT INTO `zuimoban_sys_enum`(`ename`,`evalue`,`egroup`,`disorder`,`issign`,`father`)
VALUES('$ename','$evalue','$egroup','$disorder','$issign','$father'); ";
<?php
/**
* 联动选择管理
*
* @version $Id: stepselect_main.php 2 13:23 2011-3-24 tianya $
* @package DedeCMS.Administrator
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license
* @link
*/
require_once(dirname(__FILE__)."/config.php");
CheckPurview('c_Stepselect');
require_once(DEDEINC."/datalistcp.class.php");
require_once(DEDEINC.'/enums.func.php');
/*-----------------
前台视图
function __show() { }
------------------*/
$ENV_GOBACK_URL = (isset($ENV_GOBACK_URL) ? $ENV_GOBACK_URL : 'stepselect_main.php');
if(empty($action))
{
setcookie("ENV_GOBACK_URL",$dedeNowurl,time()+3600,"/");
if(!isset($egroup)) $egroup = '';
if(!isset($topvalue)) $topvalue = 0;
$etypes = array();
$egroups = array();
$dsql->Execute('me','SELECT * FROM `zuimoban_stepselect` ORDER BY id DESC');
while($arr = $dsql->GetArray())
{
$etypes[] = $arr;
$egroups[$arr['egroup']] = $arr['itemname'];
}
if($egroup!='')
{
$orderby = 'ORDER BY disorder ASC, evalue ASC';
if(!empty($topvalue))
{
// 判断是否为1级联动
if ($topvalue % 500 == 0)
{
$egroupsql = " WHERE egroup LIKE '$egroup' AND evalue>=$topvalue AND evalue < ".($topvalue + 500);
} else {
$egroupsql = " WHERE (evalue LIKE '$topvalue.%%%' OR evalue=$topvalue) AND egroup LIKE '$egroup'";
}
}
else
{
$egroupsql = " WHERE egroup LIKE '$egroup' ";
}
$sql = "SELECT * FROM `zuimoban_sys_enum` $egroupsql $orderby";
} else {
$egroupsql = '';
$sql = "SELECT * FROM `zuimoban_stepselect` ORDER BY id DESC";
}
//echo $sql;exit;
$dlist = new DataListCP();
$dlist->SetParameter('egroup',$egroup);
$dlist->SetParameter('topvalue',$topvalue);
$dlist->SetTemplet(DEDEADMIN."/templets/stepselect_main.htm");
$dlist->SetSource($sql);
$dlist->display();
exit();
}
else if($action=='edit' || $action=='addnew' || $action=='addenum' || $action=='view')
{
AjaxHead();
include('./templets/stepselect_showajax.htm');
exit();
}
/*-----------------
删除类型或枚举值
function __del() { }
------------------*/
else if($action=='del')
{
$arr = $dsql->GetOne("SELECT * FROM `zuimoban_stepselect` WHERE id='$id' ");
if(!is_array($arr))
{
ShowMsg("无法获取分类信息,不允许后续操作!", "stepselect_main.php?".ExecTime());
exit();
}
if($arr['issystem']==1)
{
ShowMsg("系统内置的枚举分类不能删除!", "stepselect_main.php?".ExecTime());
exit();
}
$dsql->ExecuteNoneQuery("DELETE FROM `zuimoban_stepselect` WHERE id='$id'; ");
$dsql->ExecuteNoneQuery("DELETE FROM `zuimoban_sys_enum` WHERE egroup='{$arr['egroup']}'; ");
ShowMsg("成功删除一个分类!", "stepselect_main.php?".ExecTime());
exit();
}
else if($action=='delenumAllSel')
{
if(isset($ids) && is_array($ids))
{
$id = join(',', $ids);
$groups = array();
$dsql->Execute('me', "SELECT egroup FROM `zuimoban_sys_enum` WHERE id IN($id) GROUP BY egroup");
while($row = $dsql->GetArray('me'))
{
$groups[] = $row['egroup'];
}
$dsql->ExecuteNoneQuery("DELETE FROM `zuimoban_sys_enum` WHERE id IN($id); ");
//更新缓存
foreach($groups as $egropu)
{
WriteEnumsCache($egroup);
}
ShowMsg("成功删除选中的枚举分类!", $ENV_GOBACK_URL);
}
else
{
ShowMsg("你没选择任何分类!", "-1");
}
exit();
}
else if($action=='delenum')
{
$row = $dsql->GetOne("SELECT egroup FROM `zuimoban_sys_enum` WHERE id = '$id' ");
$dsql->ExecuteNoneQuery("DELETE FROM `zuimoban_sys_enum` WHERE id='{$id}'; ");
WriteEnumsCache($row['egroup']);
ShowMsg("成功删除一个枚举!", $ENV_GOBACK_URL);
exit();
}
/*-----------------
保存类型修改
function __edit_save() { }
------------------*/
else if($action=='edit_save')
{
if(preg_match("#[^0-9a-z_-]#i", $egroup))
{
ShowMsg("组名称不能有全角字符或特殊符号!","-1");
exit();
}
$dsql->ExecuteNoneQuery("UPDATE `zuimoban_stepselect` SET `itemname`='$itemname',`egroup`='$egroup' WHERE id='$id'; ");
ShowMsg("成功修改一个分类!", "stepselect_main.php?".ExecTime());
exit();
}
/*-----------------
保存新类型
function __addnew_save() { }
------------------*/
else if($action=='addnew_save')
{
if(preg_match("#[^0-9a-z_-]#i", $egroup))
{
ShowMsg("组名称不能有全角字符或特殊符号!", "-1");
exit();
}
$arr = $dsql->GetOne("SELECT * FROM `zuimoban_stepselect` WHERE itemname LIKE '$itemname' OR egroup LIKE '$egroup' ");
if(is_array($arr))
{
ShowMsg("你指定的类别名称或组名称已经存在,不能使用!","stepselect_main.php");
exit();
}
- 上一篇:解决dede联动调用问题推荐方法
- 下一篇:dedemcs文章和列表页均使用拼音方法
☉本站的源码不会像其它下载站一样植入大量的广告。为了更好的用户体验以后坚持不打水印
☉本站只提供精品源码,源码在于可用,不在多!!希望在这里找到你合适的。
☉本站提供的整站程序,均带数据及演示地址。可以在任一源码详情页查看演示地址
☉本站所有资源(包括源码、模板、素材、特效等)仅供学习与参考,请勿用于商业用途。
☉如有其他问题,请加网站客服QQ(984818011)进行交流。
- 织梦dede首页列表页获取文章对应的tag标签
- 织梦dede导航栏目顶级和二级判断二级输出不同url
- 织梦dede标签array runphp静态生成乱码BUG解决方法
- 织梦dede如何禁止会员发布文章内容带超链接
- 织梦ajax跨域提交自定义表单和跨域验证码问题
- 织梦CMS MIP文章内容页图片适配百度MIP规范
- 织梦CMS时间格式实现XX秒前、XX分钟前、XX天前
- 织梦DedeCMS更新系统缓存增加清理沉余缓存的功能
- 织梦CMS让channelartlist标签支持currentstyle属性的
- 织梦dede自带编辑器替换百度ueditor编辑器
- 织梦DEDECMS整站动态化或整站静态化设置方法
- 织梦dede 模板路径templets目录都有什么?