欢迎光临
我们一直在努力

如何给帝国CMS批量设置文章正文第一张图片为缩略图的方法

帝国CMS教程网都提醒大家一下无论做什么操作最好先提前备份一下网站和网站数据库。

备份方法:首先打开网站后台,找到系统—系统设置—备份与恢复数据—执行SQL语句:

新闻正文字段作为主表的情况用以下SQL语句:

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='';

新闻正文字段作为副表的情况用以下SQL语句:

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;

 

赞(0) 打赏
未经允许不得转载:新起点博客 » 如何给帝国CMS批量设置文章正文第一张图片为缩略图的方法


关注公众号『新起点软件管家』

获取最新网络资源及破解软件!
带你玩转各样软件...

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏