帝国CMS批量提取正文内容到简介
最近接到一个帝国cms模板改版项目,自带的数据可能是采集的,以前的简介字段内容只截取了60个字,新模板的简介60字符太少了,不美观,想让简介都截取200个字,怎么批量修改呢,文章太多了手动改肯定不行,网上查了下帝国cms教程。分享一段可用代码。
帝国CMS批量提取正文内容到简介方法
1、先备份数据库
2、保存e/admin/ChangeByID.php
<?php
define('EmpireCMSAdmin','1');
require(../class/connect.php);
require(../class/db_sql.php);
require(../class/functions.php);
require LoadLang(pub/fun.php);
require(../class/t_functions.php);
require(../data/dbcache/class.php);
require(../data/dbcache/MemberLevel.php);
$link=db_connect();
$empire=new mysqlquery();
$tbname=news;
$sid=(int)$_GET['startid'];
$b=0;
$rs=$empire->query(SELECT id,newstext FROM {$dbtbpre}ecms_{$tbname}_data_1 WHERE id>{$sid} limit 20);
while($r=$empire->fetch($rs))
{
$smalltext='';
!$r['newstext'] or $smalltext=SubSmalltextVal($r['newstext'],200);
$smalltext=addslashes($smalltext);
$smalltext &&
$empire->query(UPDATE {$dbtbpre}ecms_{$tbname} SET smalltext='{$smalltext}' WHERE id=.$r[id]);
$b=$r['id'];
}
$b or exit('转换结束!');
echo <meta http-equiv=refresh content=1;url=ChangeByID.php?startid=.$b.>;
echo 已转换ID.$b;
db_close();
$empire=null;
?>
3、浏览器访问ChangeByID.php
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。



