好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 網站建設 > 建站知識 > dede首頁調用隨機文章定時自動更新

dede首頁調用隨機文章定時自動更新

POST TIME:2018-03-15 21:05

大家做SEO的都知道網站首頁的更新頻率直接決定了網站的收錄速度和一部分站點權重,但是我們不能實時的去更新,在這個科技如此發達的時代如果我們還在采用最原始的辦法那一定是個悲劇。沒錯,就像標題寫的一樣,自動,沒錯就是自動,全自動更新首頁的文章列表。織夢仿站教程
第一步調用隨機文章:織夢仿站教程
  織夢給出了隨機文章調用的參數如下:
{dede:arclist sort=’rand’ titlelen=48 row=16}
<li><a href=&quot;[field:arcurl/]&quot; title=&quot;[field:title/]&quot; target=&quot;_blank&quot;>[field:title/]</a></li>
{/dede:arclist}  這段列表代碼可以調用出隨機文章,并且在每次刷新動態頁面的時候都會變化,但是由于織夢是首頁生成靜態html的,所以如果不去手動生成還是不會變化,這樣就用到了下面的方法。
第二步設置定時自動更新文件:
  復制下面代碼,粘貼到一個新文件中,命名為:autoindex.php,上傳到ftp的plus文件夾中,看清楚一點是plus文件夾中,錯了位置不會生效:
<?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 = &quot;../data/last_time.inc&quot;;//記錄更新時間文件,如果不能達到目的,請檢查是否有讀取權限。
include( $fpath );
if( empty($last_time))
$last_time = 0;
if( sp_input($_GET['renew'])==&quot;now&quot;)
$last_time = 0;
if((time()-$last_time)>=$autotime )
{
define('DEDEADMIN', ereg_replace(&quot;[/]{1,}&quot;,'/',dirname(__FILE__) ) );
require_once(DEDEADMIN.&quot;/../include/common.inc.php&quot;);
require_once(DEDEINC.&quot;/arc.partview.class.php&quot;);
/*
$row = $dsql->GetOne(&quot;Select * From dede_homepageset&quot;);
$dsql->Close();
$templet=$row['templet'];
$position=$row['position'];
*/
$templet = “tnbjh/index.htm”;//這里是首頁模板位置,當前是dede默認首面位置。
$position = &quot;../index.html&quot;;
$homeFile = dirname(__FILE__).&quot;/&quot;.$position;
$homeFile = str_replace(&quot;&quot;, &quot;/&quot;, $homeFile );
$homeFile = str_replace( &quot;//&quot;, &quot;/&quot;, $homeFile );
$pv = new PartView();
$pv ->SetTemplet( $cfg_basedir.$cfg_templets_dir.&quot;/&quot;.$templet );
$pv -> SaveToHtml( $homeFile );
$pv -> Close();
$file = fopen( $fpath, &quot;w&quot;);
fwrite( $file, &quot;<?phpn&quot;);
fwrite( $file,&quot;$last_time=&quot;.time().&quot;;n&quot;);
fwrite( $file, '?>' );
fclose( $file );
}
?>  然后我們需要在首頁的模版代碼head標簽中加入一段代碼:
<script src=&quot;/plus/autoindex.php&quot; language=&quot;javascript&quot;></script>  然后點擊后臺生成,更新首頁。
  這樣就等待驗證結果吧,一點要看清楚上面的注釋,時間是以秒為單位的,默認3600秒是一小時,大家可以自行更改。



收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266