无法访问此网站
检查www.mubanm.com是否解析正确

DEDE 在后台添加栏目文档的批量复制功能

作者 : 模板猫 本文共5634个字,预计阅读时间需要15分钟 发布时间: 2021-05-13 共130人阅读

如果想要把一个栏目的所有文档复制到另一个栏目中如果没有好的办法就只能一个一个的重新建立,为了避免这种浪费时间的事,我们就在后台写一个批量复制的功能。下面是实现功能的具体步骤

修改文件dede/templets/content_batch_up.htm  修改头部脚本函数ShowHideMove()function ShowHideMove(){var selBox = document.getElementByIdx_x('moveradio');var selBox2 = document.getElementByIdx_x('copyradio');//edited by adan;090508var obj = document.getElementByIdx_x('moveField');if(selBox.checked||selBox2.checked) obj.style.display = "block";//edited by adan;090508elseobj.style.display = "none";}  添加复制栏目按钮  查找<input name="action" type="radio" class="np" value="move" id="moveradio" onClick="ShowHideMove()" />移动文档  后面添加<input name="action" type="radio" class="np" value="copy" id="copyradio" onClick="ShowHideMove()" /><!–added by adan;090508–>复制栏目文档  修改文件dede/content_batch_action.PHP  首先删除文件最后的两段代码//删除空标题内容else if($action=='delnulltitle'){$dsql->SetQuery("Select id From dede_archives where trim(title)='' ");$dsql->Execute('x');$tdd = 0;while($row = $dsql->GetObject('x')){if(DelArc($row->id)){$tdd++;}}ShowMsg("成功删除 $tdd 条记录!","JavaScript:;");exit();}//修正缩略图错误else if($action=='modddpic'){$dsql->ExecuteNoneQuery("Update dede_archives set litpic='' where trim(litpic)='litpic' ");ShowMsg("成功修正缩略图错误!","javascript:;");exit();}  上面2段代码,官方人员竟然把上面2段代码搞重复了,先汗一个!  然后在最后添加下面代码//start 添加复制栏目文章功能 added by adan;090508else if($action=='copy'){if(empty($typeid)){ShowMsg('该操作必须指定栏目!','javascript:;');exit();}$typeold = $dsql->GetOne("Select * From `dede_arctype` where id='$typeid'; ");$typenew = $dsql->GetOne("Select * From `dede_arctype` where id='$newtypeid'; ");if(!is_array($typenew)){$dsql->Close();ShowMsg("无法检测复制到的新栏目的信息,不能完成操作!","javascript:;");exit();}if($typenew['ispart']!=0){$dsql->Close();ShowMsg("你不能把数据复制到非最终列表的栏目!","javascript:;");exit();}if($typenew['channeltype']!=$typeold['channeltype']){$dsql->Close();ShowMsg("不能把数据复制到内容类型不同的栏目!","javascript:;");exit();}$gwhere .= " And channel='".$typenew['channeltype']."' And title like '%$keyword%'";$ch = $dsql->GetOne("Select addtable From `dede_channeltype` where id={$typenew['channeltype']} ");$addtable = $ch['addtable'];$dsql->SetQuery("Select * From `dede_archives` where typeid='$typeid'");$dsql->Execute('c');$tdd = 0;while($row = $dsql->GetObject('c')){$senddate = time();$sortrank = AddDay($senddate,0);//第二个参数是排序值,参考article_add.php$ID = $row->id;$typeid = $newtypeid;//$newtypeid$sortrank = $row->sortrank;$flag = $row->flag;$ismake = $row->ismake;$channelid = $row->channel;$arcrank = $row->arcrank;$click = $row->click;$money = $row->money;$title = addslashes($row->title);//需要添加addslashes()转换; adan;090508$shorttitle = $row->shorttitle;$color = $row->color;$writer = $row->writer;$source = $row->source;$litpic = $row->litpic;$pubdate = $row->pubdate;$adminid = $cuserLogin->getUserID();$notpost = $row->notpost;$description = addslashes($row->description);//需要添加addslashes()转换; adan;090508$keywords = $row->keywords;require_once(DEDEADMIN."/inc/inc_archives_functions.php");//生成文档ID$arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$adminid);if(empty($arcID)){ShowMsg("无法获得主键,因此无法进行后续操作!","-1");exit();}//加入数据表dede_archives的SQL语句//———————————-$inQuery = "INSERT INTO `dede_archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,lastpost,scores,goodpost,badpost,notpost,description,keywords,filename)VALUES ('$arcID','$typeid','','$sortrank','$flag','$ismake','$channelid','$arcrank','0','$money','$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','0','0','0','0','0','$description','$keywords','');";if(!$dsql->ExecuteNoneQuery($inQuery)){$gerr = $dsql->GetError();$dsql->ExecuteNoneQuery("Delete From `dede_arctiny` where id='$arcID'");ShowMsg("把数据保存到数据库主表 `dede_archives` 时出错,请把相关信息提交给DedeCms官方。".str_replace('"','',$gerr),"javascript:;");exit();}//保存到附加表$cts = $dsql->GetOne("Select addtable From `dede_channeltype` where id='$channelid' ");$addtable = trim($cts['addtable']);if(empty($addtable)){$dsql->ExecuteNoneQuery("Delete From `dede_archives` where id='$arcID'");$dsql->ExecuteNoneQuery("Delete From `dede_arctiny` where id='$arcID'");ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。","javascript:;");exit();}$useip = GetIP();$redirecturl = $addRow['redirecturl'];$templet = $addRow['templet'];$addRow = $dsql->GetOne("Select * from `{$addtable}` where aid='$ID'");$body = addslashes($addRow["body"]);$query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,templet,userip,body) Values('$arcID','$typeid','$redirecturl','$templet','$useip','$body')";if(!$dsql->ExecuteNoneQuery($query)){$gerr = $dsql->GetError();$dsql->ExecuteNoneQuery("Delete From `dede_archives` where id='$arcID'");$dsql->ExecuteNoneQuery("Delete From `dede_arctiny` where id='$arcID'");ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCms官方。".str_replace('"','',$gerr),"javascript:;");exit();}else $tdd++;}if($tdd>0){$jumpurl= "makehtml_archives_action.php?endid=$endid&startid=$startid";$jumpurl .= "&typeid=$newtypeid&pagesize=20&seltime=$seltime";$jumpurl .= "&stime=".urlencode($starttime)."&etime=".urlencode($endtime);ShowMsg("成功复制了 $tdd 条记录,准备重新生成HTML…",$jumpurl);}else ShowMsg("完成操作,没复制任何数据…","javascript:;");exit();}

(转载别人的文章,我只是想更好的跟大家分享,这些都是我也遇到过的问题)

1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!4105897@qq.com
2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有站币奖励和额外收入!

模板猫 » DEDE 在后台添加栏目文档的批量复制功能

常见问题FAQ

免费下载或者贵宾会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 《免责声明》。
点击下载链接不跳转怎么回事?
您好,QQ内打开是不跳转的,一少部分浏览器也不跳转,一般的UC了,搜狗 360等浏览器都可以跳转。
可以直接把资源发给我吗?
您好,付费资源可以直接把链接发送给您,免费资源不提供任何帮助,软件资源自测,或者请站长喝红牛!