帝国cms后台批量添加tags和前台录入tags的方法
发布时间:2022-06-29 20:30:37 所属栏目:教程 来源:互联网
导读:修改步骤: 1、以下代码加入到admin/ecmsinfo.php 在任意2个elseif中间插入就行: elseif($enews==AddTags_all)//列表批量添加Tags{$classid=$_POST[classid];$id=$_POST[id];$tags=$_POST[add_listtags];$newstime=time();eInsertTags2($tags,$classid,$id,
修改步骤: 1、以下代码加入到admin/ecmsinfo.php 在任意2个elseif中间插入就行: elseif($enews=="AddTags_all")//列表批量添加Tags{$classid=$_POST['classid'];$id=$_POST['id'];$tags=$_POST['add_listtags'];$newstime=time();eInsertTags2($tags,$classid,$id,$newstime);} 2、将以下代码加入到class/uesrfun.php //加入TAG表 function eInsertTags2($tags,$classid,$id,$newstime){ global $empire,$dbtbpre,$class_r; if(!trim($tags)) { printerror("TAGS信息不能为空", "", 1, 0, 1); return ''; } $count = count($id); //统计ID数量 $tags = RepPostVar($tags); $tag = explode(",", $tags); if (emptyempty($count)) { printerror("未选择信息ID", "", 1, 0, 1); } if (count($tag)>1) { printerror("只能添加一个TAGS词", "", 1, 0, 1); } $classid=(int)$classid; $id[$i] = (int)$id[$i]; $mid=(int)$class_r[$classid][modid]; for($i=0;$i<$count;$i++) { $tbname=$class_r[$classid][tbname];//获取表名 $r=$empire->fetch1("select tagid from {$dbtbpre}enewstags where tagname='$tags' limit 1"); $t = $empire->fetch1("select infotags from {$dbtbpre}ecms_".$tbname." where id='$id[$i]'"); $taga=$t['infotags'].",".$tags; //组合TAGS $tagb[$i] = explode(",",$taga); //设置数组 $tagc=array_values(array_unique($tagb[$i])); //数组排重 for($t=0;$t<count($tagc);$t++) {//二级子循环TAGS数组输出 $newtags[$i].= ",".$tagc[$t]; } if($r[tagid]) { $datar=$empire->fetch1("select tagid,classid,newstime from {$dbtbpre}enewstagsdata where tagid='$r[tagid]' and id='$id[$i]' and mid='$mid' limit 1"); if($datar[tagid]) { if($datar[classid]!=$classid||$datar[newstime]!=$newstime) { $empire->query("update {$dbtbpre}enewstagsdata set classid='$classid',newstime='$newstime' where tagid='$r[tagid]' and id='$id[$i]' and mid='$mid' limit 1"); } } else { $empire->query("update {$dbtbpre}enewstags set num=num+1 where tagid='$r[tagid]'"); $empire->query("update {$dbtbpre}ecms_".$tbname." set infotags='".trim($newtags[$i],",")."' where id='$id[$i]'"); $empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$r[tagid]','$classid','$id[$i]','$newstime','$mid');"); } } else { $empire->query("update {$dbtbpre}ecms_".$tbname." set infotags='".trim($newtags[$i],",")."' where id='$id[$i]'"); $empire->query("insert into {$dbtbpre}enewstags(tagname,num,isgood,cid) values('$tags',1,0,0);"); $tagid=$empire->lastid(); $empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$tagid','$classid','$id[$i]','$newstime','$mid');"); } } printerror("批量添加TAGS成功", "", 1, 0, 1); } 3、信息管理列表模板最后一列修改成以下代码 e/data/html/list/文件夹内的listinfo.php文件. 把<td height="25" colspan="8"> <font color="#666666">备注:多选框蓝色为未审核信息;发布者红色为会员投稿;信息ID粗体为未生成,点击ID可刷新页面.</font></td> 修改为: <td height="25" colspan="8"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="68%" height="25"> <font color="#666666">备注:多选框蓝色为未审核信息;发布者红色为会员投稿;信息ID粗体为未生成,点击ID可刷新页面.</font> </td> <td width="32%"> <input type="text" name="add_listtags" id="add_listtags" size="50" value="" /> <input type="submit" name="Submit100" value="添加TAGS" onClick="document.listform.enews.value='AddTags_all';document.listform.action='ecmsinfo.php';"> </td> </tr> </table> </td> 增加前台投稿录入tags功能,备份 /e/class/qinfofun.php 文件后,打开编辑: $sql=$empire->query("insert into {$dbtbpre}ecms_".$tbname. 将这段代码: $sql=$empire->query("insert into {$dbtbpre}ecms_".$tbname."(classid,onclick,newspath,keyboard,keyid,userid,username,ztid,checked,istop,truetime,ismember,dokey,isgood,titlefont,titleurl,filename,groupid,newstempid,plnum,firsttitle,isqf,userfen,totaldown,closepl,havehtml,lastdotime,haveaddfen,infopfen,infopfennum,votenum,stb,ttid".$ret_r[0].") values('$classid',0,'$newspath','$keyboard','$keyid','".$muserid."','".addslashes($musername)."','$ztid','$checked',0,'$truetime',1,1,0,'$titlefont','','',0,'$newstempid',0,0,'$isqf',0,0,0,'$havehtml','$truetime','$haveaddfen',0,0,0,'$ret_r[4]','$ttid'".$ret_r[1].");"); 替换为: $sql=$empire->query("insert into {$dbtbpre}ecms_".$tbname."(classid,onclick,newspath,keyboard,keyid,userid,username,ztid,checked,istop,truetime,ismember,dokey,isgood,titlefont,titleurl,filename,groupid,newstempid,plnum,firsttitle,isqf,userfen,totaldown,closepl,infotags,havehtml,lastdotime,haveaddfen,infopfen,infopfennum,votenum,stb,ttid".$ret_r[0].") values('$classid',0,'$newspath','$keyboard','$keyid','".$muserid."','".addslashes($musername)."','$ztid','$checked',0,'$truetime',1,1,0,'$titlefont','','',0,'$newstempid',0,0,'$isqf',0,0,0,'".addslashes($add[infotags])."','$havehtml','$truetime','$haveaddfen',0,0,0,'$ret_r[4]','$ttid'".$ret_r[1].");"); 其实就是新增了两个部分,自己仔细看,然后找到,扣点记录,在这行上面新增: //TAGS $oldinfotags=''; if($add['infotags']&&$add['infotags']<>$oldinfotags) { $tagtime=emptyempty($newstime)?time():to_time($newstime); eInsertTags($add['infotags'],$classid,$id,$tagtime); } 保存文件,在投稿表单里新增tags的投稿框即可,如: <input name="infotags" type="text" id="infotags" value="" size="">。 (编辑:随州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |