如何設(shè)置網(wǎng)站首頁隨機文章板塊自動更新

2021-04-21    分類: 網(wǎng)站建設(shè)

使用織夢的朋友都知道首頁添加完隨機文章板塊后不會實現(xiàn)自動更新,那怎樣才能實現(xiàn)隨機文章自動更新呢?

第一步、復制下面紅色部分內(nèi)容到記事本,完成后,另存為名稱為autoindex.php的文件,并將其上傳到織夢plus文件夾
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”;
$position = "../index.html";
$homeFile = dirname(__FILE__)."/".$position;
$homeFile = str_replace("\\", "/", $homeFile );
$homeFile = str_replace( "http://", "/", $homeFile );
$pv = new PartView();
$pv ->SetTemplet( $cfg_basedir.$cfg_templets_dir."/".$templet );
$pv -> SaveToHtml( $homeFile );
$pv -> Close();
$file = fopen( $fpath, "w");
fwrite( $file, "fwrite( $file,"\$last_time=".time().";\");
fwrite( $file, '?>' );
fclose( $file );
}
?>
  第二步、登錄織夢后臺,在head.htm文件中加入下面代碼,我加在了前面

溫馨提示:千萬不要上傳到錯誤位置,否則會調(diào)用不成功!

本文標題:如何設(shè)置網(wǎng)站首頁隨機文章板塊自動更新
文章源于:http://www.muchs.cn/news/109210.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)網(wǎng)站設(shè)計、虛擬主機電子商務(wù)、全網(wǎng)營銷推廣、靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

猜你還喜歡下面的內(nèi)容

成都網(wǎng)頁設(shè)計公司

網(wǎng)站建設(shè)知識

各行業(yè)網(wǎng)站