欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

dedecms

當(dāng)前位置:主頁 > CMS教程 > dedecms >

織夢DedeCMS定時(shí)自動生成首頁HTML的實(shí)現(xiàn)方法

來源:本站原創(chuàng)|時(shí)間:2020-01-11|欄目:dedecms|點(diǎn)擊: 次

只需要制作一個文件然后在首頁模板添加一句代碼就可以實(shí)現(xiàn)讓織夢DedeCMS自動生成首頁html,具體方法如下:

第一步、需要在首頁調(diào)用隨機(jī)文章,這樣每次自動更新才會有更新的效果,隨機(jī)文章調(diào)用標(biāo)簽如下:

{dede:arclist sort='rand' titlelen=48 row=16}
<li><a href="[field:arcurl/]" title="[field:title/]" target="_blank">[field:title/]</a></li>
{/dede:arclist}

這段代碼調(diào)用出的文章在每次自動生成首頁的時(shí)候都會變化。

第二步、寫一個觸發(fā)定時(shí)自動更新的php文件:

復(fù)制下面代碼,粘貼到一個新文件中,命名為:autoindex.php,上傳到ftp的plus文件夾中,看清楚一點(diǎn)是plus文件夾中,錯了位置不會生效:

<?php
function sp_input( $text )
{
$text = trim( $text );
$text = htmlspecialchars( $text );
if (!get_magic_quotes_gpc())
return addslashes( $text );
else
return $text;
}
$autotime = 10800;//自動更新時(shí)間,單位為秒
$fpath = "../data/last_time.inc";//記錄更新時(shí)間文件,如果不能達(dá)到目的,請檢查是否有讀取權(quán)限。
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 = “downpk/index.htm”;//這里是首頁模板位置,當(dāng)前是dede默認(rèn)首面位置。
$position = "../index.html";
$homeFile = dirname(__FILE__)."/".$position;
$homeFile = str_replace("\\", "/", $homeFile );
$homeFile = str_replace( "//", "/", $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 );
}
?>

第三步、在首頁的模版代碼head標(biāo)簽中引入觸發(fā)文件代碼:

<script src="/plus/autoindex.php" type="text/javascript"></script>

然后手動更新一下首頁,接下來在設(shè)置的時(shí)間過了以后如果有用戶訪問首頁就會觸發(fā)自動更新文件,首頁就會自動更新一次。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持秀站網(wǎng)。

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有