中药方大全小图标
您当前的位置:首页 > 其他 > 网站日记

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

提示: 阅读权限:公开  来源:jiuhecai  作者:海蓝

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

 

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

帝国cms tags

修改步骤:

  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. 信息管理列表模板最后一列修改成以下代码,在e/data/html/list/文件夹内

 

<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>

帝国cms箭头指的两个文件都修改

 

 

 

3.将以下代码加入到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<$count;$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);   



 

tags: 帝国cms tags 批量 列表页 帝国
返回顶部
推荐资讯
视频:田纪钧讲关节不痛的秘密、膝关节拉筋法
视频:田纪钧讲关节不
白露到了,你还好吗?
白露到了,你还好吗?
尿疗与断食
尿疗与断食
给风疹反复发作女孩的药方(组图)
给风疹反复发作女孩的
相关文章
栏目更新
栏目热门
  1. 帝国cms全站搜索的分页格式如何修改-流程
  2. libreoffice7的命令大全
  3. 帝国cms插件之标题生成标题图片
  4. 帝国cms插件安装模板
  5. useragent两千条,爬虫专用
  6. 帝国cms插件如何兼容gbk和utf8
  7. 帝国cms插件之迅搜
  8. 帝国cms用户上传文件名的命名规则及修改方
  9. 帝国cms7.2函数大全
  10. 帝国cms代码片段备忘录