DEDECMS自动更新首页HTML的方法(转)

DEDECMS自动更新首页HTML的方法如下:

1、在首页模板<head>区里插入如下代码后,手动生成一次首页HTML,以后就会根据你设定的时间自动更新了。

<script src="/plus/auto_makehtml_homepage.php" language="javascript"></script>

2、把以下代码保存为 auto_makehtml_homepage.php ,放到 /plus/ 下。

<?php
require_once(dirname(__FILE__)."/../include/config_base.php");
require_once(dirname(__FILE__)."/../include/inc_arcpart_view.php");
$lasttime=filemtime(dirname(__FILE__)."/../index.html");
$interval=3600;//3600秒,测试时可改小点如60,方便查看效果。
if((time()-$lasttime)>$interval)
{
 $dsql = new DedeSql(false);
 $row  = $dsql->GetOne("Select * From #@__homepageset");
 $dsql->Close();
 $templet=$row['templet'];
 $position=$row['position'];
 $homeFile = dirname(__FILE__)."/".$position;
 $homeFile = str_replace("\\","/",$homeFile);
 $homeFile = str_replace("//","/",$homeFile);
 $templet = str_replace("{style}",$cfg_df_style,$templet);
 $pv = new PartView();
 $pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
 $pv->SaveToHtml($homeFile);
 $pv->Close();
}

?>

注:网上转载的,自己没用到,没做测试,如果测试成功请告知,谢谢!
原文地址:https://www.cnblogs.com/Byrd/p/2161660.html