详情页

帝国CMS插件批量王使用说明

时间:2024年03月28日

编辑:佚名

【使用法】后台,添加sql语句,并保存,要求名称[plw]开头。
模板内容参考示范代码。主表副表字段都集成在$r数组中了。要求把最后修改的字段名写到$listtemp变量中,多个用逗号分开。
代码1:同时修改多个字段。要点--最后把需要修改的字段名写到$listtemp变量中,多个用逗号分开。
$r['newstext'].='777';
$r['smalltext']='777'.$r['smalltext'];
$r['title']='777'.$r['title'];
$listtemp="newstext,title,smalltext";
代码2:修改发布时间字段
【示范代码】
$r['newstime']=to_time('1988-12-30');
$listtemp="newstime";
代码3:批量修改smalltext
【示范代码】
$r['newstext']=stripslashes($r['newstext']);
$smalltext=SubSmalltextVal($r['newstext'],100);
$r['newstext']=addslashes($smalltext);
$listtemp="smalltext";
【示范代码】
global $public_r;
$listtemp='smalltext';
$r['newstext']=stripslashes($r['newstext']);
$smalltext=SubSmalltextVal($r['newstext'],$public_r['smalltextlen']);
$r['smalltext']=addslashes($smalltext);
$listtemp="smalltext";
【代码4】批量取消审核
$jhc=$empire->query("update {$dbtbpre}ecms_{$tbname}_index set checked=0 where id='$r[id]'");
MoveCheckInfoData($tbname,1,$r['stb'],"id='{$r[id]}'");
AddClassInfos($r['classid'],'','-1');
DelNewsFile($r[filename],$r[newspath],$r[classid],$r[$pf],$r[groupid]);
$listtemp='';
【代码5】批量审核
//未审核表转换 MoveCheckInfoData($class_r[$r[classid]][tbname],0,$r['stb'],"id='$r[id]'"); //更新栏目信息数 AddClassInfos($r['classid'],'','+1'); //刷新信息 GetHtml($r['classid'],$r['id'],$r,1); $listtemp='';
【代码6】批量修改友情链接的说明
$r['lsay']='你好我就是测试一下好用吗';
$listtemp="lsay";
【代码7】把内容中的第一张图片设置为标题图片
第一步,新建一个自定义页面模板,标题为---[批量王]提取内容图片到标题,内容如下:
if(!$r[titlepic]){
  $newstext=stripslashes($r['newstext']);
         $pattern = '/<img(?=\s).*?(?<=\s)src="(.+?)"/i'; 
          preg_match($pattern, $newstext, $matches);
  if($matches){
                $r[titlepic]= $matches[1];//返回第一张图片地址
                if(!strstr($r[titlepic],'://')){$r[titlepic]=$_SERVER[HTTP_ORIGIN].'/'.ltrim($r[titlepic],'/'); }
        }
}
$listtemp='titlepic';
第二步,打开批量王,选择出这模板,执行就可以了。

附注:使用mysql语句完成本任务的方法
执行以下脚本的时候请 先备份数据库!文本存放的新闻正文字段不可用!
新闻正文字段作为主表的情况用以下语句:
update  phome_ecms_news  set  titlepic  =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext,  'src=',  -1),'.gif',1),'"',''),'.gif')  where  newstext  like  '%.gif%'  and  titlepic='';
update  phome_ecms_news  set  titlepic  =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext,  'src=',  -1),'.jpg',1),'"',''),'.gif')  where  newstext  like  '%.jpg%'  and  titlepic='';
update  phome_ecms_news  set  titlepic  =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext,  'src=',  -1),'.png',1),'"',''),'.png')  where  newstext  like  '%.png%'  and  titlepic='';
新闻正文字段作为副表的情况用以下语句:
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext,  'src=',  -1),'.gif',1),'"',''),'.gif')  where  a.newstext  like  '%.gif%'  and  b.titlepic='' and a.id=b.id;
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext,  'src=',  -1),'.jpg',1),'"',''),'.jpg')  where  a.newstext  like  '%.jpg%'  and  b.titlepic='' and a.id=b.id;
update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext,  'src=',  -1),'.png',1),'"',''),'.png')  where  a.newstext  like  '%.png%'  and  b.titlepic='' and a.id=b.id;
【代码8】批量添加tags
网站已经有大量的tags存在,但是有些文章的标题含有tags,然而没有被添加。本段代码在批量王中执行,完成tags的添加。
$infotagsr=explode(',',$r['infotags']);
$r[title]=addslashes($r[title]);
$jhcsql=$empire->query("select tagname,tagid from {$dbtbpre}enewstags where locate(tagname,'$r[title]')>0");
while($jhcr=$empire->fetch($jhcsql)){
   if(in_array($jhcr[tagname],$infotagsr))continue;
   $infotagsr[]=$jhcr[tagname];
   $empire->query("update {$dbtbpre}enewstags set num=num+1 where tagid='$jhcr[tagid]'");
   $classid=(int)$r[classid];   
   $mid=(int)$class_r[$classid][modid]; 
   $empire->query("insert into  {$dbtbpre}enewstagsdata set tagid={$jhcr[tagid]},classid=$classid,id={$r[id]},newstime='$r[newstime]',mid=$mid");
}
$r['infotags']=trim(implode(',',$infotagsr),',');
$listtemp='infotags';
【代码9】批量删除重复的信息
打开批量王,选择需要操作的数据表,比如news
操作函数选择: 批量删除
主表条件填写:
title in
    (select title FROM phome_ecms_news group by title having count(*)>1)
and id not in
    (select id FROM phome_ecms_news group by title having count(*)>1)
相关文章
猜你需要