dedecms自动生成首页静态的方法

时间:2014-08-09

 

最近将网站改版,用了dedecms程序,看了下首页文件,发现没有自动生成静态首页文件index.html ,这样如果删除了index.html,那么访问网站,则会出现首页404错误。故修改了首页程序,加上了判断,让程序可以自动生成首页文件!
代码如下:

<?php
if(!file_exists(dirname(__FILE__).’/data/common.inc.php’)) {
header(‘Location:install/index.php’); exit();
} //自动生成HTML版,加上
//!file_exists(dirname(__FILE__).’/index.html’),如果不存在index.html,则自动生成index.html
if(isset($_GET['upcache']) || !file_exists(dirname(__FILE__).’/index.html’)) {
require_once (dirname(__FILE__) . "/include/common.inc.php"); require_once DEDEINC."/arc.partview.class.php";
$GLOBALS['_arclistEnv'] = ‘index’; $row = $dsql->GetOne("Select * From `dede_homepageset`");
$row['templet'] = MfTemplet($row['templet']); $pv = new PartView();
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']); $pv->SaveToHtml(dirname(__FILE__).’/index.html’);
include(dirname(__FILE__).’/index.html’); exit();
} else
{ header(‘HTTP/1.1 301 Moved Permanently’);
header(‘Location:index.html’); }
?>
加 上!file_exists(dirname(__FILE__).’/index.html’) 这句即可实现自动生成index.html . 当然没有这句也没太大的问题,但是万一不小心删掉了index.html,而有没有及时的生成index.html ,那么问题就出现了。

上一条:DedeCMS专题页面文章调用的多种方法 下一条:dedecms单页文档调用 likesgpage&likepage 时标签修改方法

相关文章

最新文章