DEDECMS默认是静态首页需要手动更新,但是很多时候我们采集完了懒的去搞生成,从论坛上找了几个方法没有能用到,遂即咨询非人类阿杰,结果真找对人了
需要在plus目录放两个文件auto_makehome.php和last_config.php
auto_makehome.php文件内容如下
<?php
require_once('last_config.php');
if((time()-$lasttime)>600)
{
define('DEDEADMIN', ereg_replace("[/\\]{1,}",'/',dirname(__FILE__) ) );
require_once(DEDEADMIN."/../include/common.inc.php");
require_once(DEDEINC."/arc.partview.class.php");
$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();
$file = fopen("last_config.php","w");
fwrite($file,"<?php\n");
fwrite($file,"\$lasttime=".time().";\n");
fwrite($file,'?>');
fclose($file);
}
?>
last_config.php文件内容如下
<?php
$lasttime=1255051301;
?>
保证last_config.php文件的可写
然后在用户常访问的页面或者JS里调用一个JS<script src="/plus/auto_makehome.php" language="javascript"></script>
目的是通过用户的触发生成首页,
该文件为默认首页的定时生成功能,如果需修改,请根调用先关的数据库文件,或者直接复制一个首页数据库文件homepagese稍做修改比如生成页面一直模版设置一下,然后调用就可以实现自定义页面的定时生成,在此感谢阿杰