織夢dedecms定時自動更新首頁的方法,織夢技術
導讀:織夢技術織夢技術織夢dedecms定時自動更新首頁的方法如下: 1、在 根目錄/plus 目錄下新建一個php文件,命名為:autoindex.php 2、將以下代碼復制到 adede后臺模板免費織夢模板。
織夢dedecms定時自動更新首頁的方法如下:
1、在 根目錄/plus 目錄下新建一個php文件,命名為:autoindex.php
2、將以下代碼復制到 autoindex.php 文件
<?php
function sp_input( $text )
{
$text = trim( $text );
$text = htmlspecialchars( $text );
if (!get_magic_quotes_gpc())
return addslashes( $text );
else
return $text;
}
$autotime = 3600;//自動更新時間,單位為秒,這里我設為一小時,大家可以自行更改。
$fpath = "../data/last_time.inc";//記錄更新時間文件,如果不能達到目的,請檢查是否有讀取權限。
include( $fpath );
if( empty($last_time))
$last_time = 0;
if( sp_input($_GET['renew'])=="now")
$last_time = 0;
if((time()-$last_time)>=$autotime )
{
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 dede_homepageset");
$dsql->Close();
$templet=$row['templet'];
$position=$row['position'];
*/
$templet = “tnbjh/index.htm”;//這里是首頁模板位置,當前是dede默認首面位置。
$position = "../index.html";
$homeFile = dirname(__FILE__)."/".$pdede5.7模板osition;
$homeFile = str_replace("\\", "/", $homeFile );
$homeFile = str_replace( "//", &qu織夢模板安裝ot;/", $homeFile );
$pv = new PartView();
$pv ->SetTemplet( $cfg_basedir.$cfg_templets_dir."/".$templet );
$pv -> SaveToHtml( $homeFile );
$pv -> Close();
$file = fopen( $fpath, "w");
fwrite( $file, "<?php\n");
fwrite( $file,"\$last_time=".time().";\n");
fwrite( $file, '?>' );
fclose( $file );
}
?>
3、在首頁模板的<head></head>標簽中加入如下代碼
<script src="/plus/autoindex.php" language="javascript"></script>
以上就是本文章的內容,希望對大家有所幫助
相關dede后臺模板免費織夢模板。聲明: 本文由我的SEOUC技術文章主頁發布于:2023-07-18 ,文章織夢dedecms定時自動更新首頁的方法,織夢技術主要講述首頁,自動更新,織夢網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_29869.html