摆渡人

生活是一艘船,需要我们去掌舵,摆渡人生,摆渡命运,摆渡智慧

« win记事本默认编码怎么搞定水蛭的药用价值 »

DEDE自动更新首页自定义页面解决方案

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稍做修改比如生成页面一直模版设置一下,然后调用就可以实现自定义页面的定时生成,在此感谢阿杰


原创文章如转载,请注明:转载自摆渡人 [ http://www.baidumen.com ]
本文链接地址:http://www.baidumen.com/baiduren/5303.html
  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新评论及回复

最近发表

Powered By 摆渡人 Code detection by Codefense

摆渡人-惊涛版权所有 冀ICP备05027985号