帝国 listenews.php,帝国cms7.2后台信息列表页批量添加tags

有些时候,我们需要对几十条文章数据批量添加Tags,而帝国CMS并没有自带这个功能,所以本文介绍了在列表页面批量添加Tags的方法。网上流传的是6.6版本使用的,这里修改后7.0,7.2版本可用的。

本文介绍通过修改程序源码实现在管理资讯时批量添加Tags,效果如下图:

66f0582312739917b85cc67ec34fde92.png

修改步骤:

1、打开/e/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、打开/e/data/html/list/alllistinfo.php及listinfo.php(两个文件都要修改):

查找:

备注:多选框蓝色为未审核信息;发布者红色为会员投稿;信息ID粗体为未生成,点击ID可刷新页面.

修改为:

备注:多选框蓝色为未审核信息;发布者红色为会员投稿;信息ID粗体为未生成,点击ID可刷新页面.

3、将以下代码加入到/e/class/userfun.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数量

if (empty($count)){printerror("未选择信息ID", "", 1, 0, 1);}

$tags = RepPostVar($tags);

$tag = explode(",", $tags);

if (count($tag)>1) {  printerror("只能添加一个TAGS词", "", 1, 0, 1); }

$classid=(int)$classid;

$mid=(int)$class_r[$classid][modid]; //获取模型id

$tbname=$class_r[$classid][tbname];//获取表名

for($i=0;$i

{

$id[$i] = (int)$id[$i];

$fb = $empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$id[$i]' limit 1");

$classid=$fb['classid'];

$newstime=$fb['newstime'];

$ftbname=$dbtbpre."ecms_".$tbname."_data_".$fb['stb'];

$r=$empire->fetch1("select tagid from {$dbtbpre}enewstags where tagname='$tags' limit 1");

$t = $empire->fetch1("select infotags from {$ftbname} where id='$id[$i]'");

$taga=$t['infotags'].",".$tags; //组合TAGS

$taga=trim($t['infotags'].",".$tags,","); //组合TAGS

$tagb[$i] = explode(",",$taga); //设置数组

$tagc=array_values(array_unique($tagb[$i])); //数组排重

$newtags[$i]=implode(",",$tagc);

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 {$ftbname} set infotags='$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 {$ftbname} set infotags='$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);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值