在帝国cms中内容模板中需要根据关键词调用相关内容,那么关键词中就需要有相同的关键词,下面介绍一下如何批量添加关键词和ag
在帝国cms中内容模板中需要根据关键词调用相关内容,那么关键词中就需要有相同的关键词,下面介绍一下如何批量添加关键词和tag
信息列表批量添加TAG,批量复制到关键词,7.5可用。
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<$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到关键词
function eCopyTag2Key($classid,$id,$newstime){
global $empire,$dbtbpre,$class_r;
$count = count($id); //统计ID数量
if (empty($count))
{//如果id没选中
printerror("未选择信息ID", "", 1, 0, 1);
}
$classid=(int)$classid;//这一步可省略
$mid=(int)$class_r[$classid][modid];//取modid值,这一步可省略
for($i=0;$i<$count;$i++)
{
$id[$i] = (int)$id[$i];
$tbname=$class_r[$classid][tbname];//获取表名
$r = $empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$id[$i]' limit 1");
$t = $empire->fetch1("select infotags from {$dbtbpre}ecms_".$tbname."_data_".$r['stb']." where id='$id[$i]'");//从信息表中取infotags和keyboard值
$t=array_merge($r,$t);
$taga=$t['infotags'].",".$t['keyboard']; //组合TAGS:在原有的infotags值上加上新keyboard
$tagb[$i] = explode(",",$taga); //设置数组:用,分割tag
$tagc=array_values(array_unique($tagb[$i])); //数组排重:排除重复?
for($t=0;$t<count($tagb[$i]);$t++)
{//二级子循环TAGS数组输出
$newtags[$i].= ",".$tagc[$t];
}
$empire->query("update {$dbtbpre}ecms_".$tbname." set keyboard='".trim($newtags[$i],",")."' where id='$id[$i]'");//将新生成的keyboard写入到表中
}
printerror("已成功将TAGS批量复制到关键词字段", "", 1, 0, 1);
}
e\admin\ecmsInfo.php 在任意2个elseif中间插入
elseif($enews=="CopyTag2Key")//列表批量复制Tags为关键词
{
$classid=$_POST['classid'];
$id=$_POST['id'];
$newstime=time();
eCopyTag2Key($classid,$id,$newstime);
}
elseif($enews=="AddTags_all")//列表批量添加Tags
{
$classid=$_POST['classid'];
$id=$_POST['id'];
$tags=$_POST['add_listtags'];
$newstime=time();
eInsertTags2($tags,$classid,$id,$newstime);
}
e/data/html/list/ listinfo.php和alllistinfo.php
<font color="#666666">备注:多选框蓝色为未审核信息;发布者红色为会员投稿;信息ID粗体为未生成,点击ID可刷新页面.</font>前面加以下
<input type="text" name="add_listtags" id="add_listtags" size="50" value="" />
<input type="button" name="Submit" value="选择" onclick="window.open('tags/ChangeTags.php?form=listform&field=add_listtags<?=$ecms_hashur['ehref']?>','','width=700,height=550,scrollbars=yes');">
<input type="submit" name="Submit100" value="批量添加TAGS" onClick="document.listform.enews.value='AddTags_all';document.listform.action='ecmsinfo.php';">
<input type="submit" name="Submit99" value="批量复制TAGS到关键词" onClick="document.listform.enews.value='CopyTag2Key';document.listform.action='ecmsinfo.php';">
帝国cms内容页按照文章关键词调用相应内容的方法教程-帝国cms二次开发中心
http://www.xlkjgs.com/notes/ecms/12107.html
本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。
2021-02-08
2021-02-08
2022-10-26
2021-02-27
2021-08-27
2021-08-27
2021-08-27
2022-04-12