動態獲取織夢CMS最新更新 利於收錄的SiteMap.php文件

  之前有通過單頁的形式,製作了一個SiteMap.html地圖文件,也就是將一些最新更新的內容列出來,方便搜索引擎訪問,利於收錄,但還需要用戶手動去更新單頁文件才能獲得最新更新,相對來說比較麻煩。

  所以現在乾脆直接用PHP+SQL語句直接在數據庫裏面調用最新更新的內容,這樣比較方便快捷,而且不需要人工來更新,也沒有什麼明顯缺點。有些同學會認爲動態頁面不利於收錄,但這個動態頁面也僅是一個地圖文件而已,主要是發揮橋樑紐帶作用,可以讓蜘蛛比較方便的到達最新更新的頁面,便於收錄。對於每天大量更新的站點來說,作用還是很大的,比如用織夢採集俠每天大量採集的用戶來說還是挺有幫助的。只需要在footer.htm模板裏面加入個指向這個sitemap.php文件就行。

  將這個文件上傳至你網站的根目錄下,訪問 http://你的域名/sitemap.php ,就能看到效果了。

<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<?php

/**
 * @version    $Id sitemap.php 1001 2011-6-18 qjp $
 * @copyright  Copyright (c) 2010-2011,qjp
 * @link       http://www.qjp.name
 */

require dirname(__FILE__).'/include/common.inc.php';
$db->Execute('me',""select id,title from #@__archives order by id desc limit 0,100"");
$list = array();
while($rs = $db->GetArray('me'))
{

    $arc = GetOneArchive($rs['id']);
    $list[] = array('arcurl'=>$arc['arcurl'],'title'=>$rs['title']);
}
?>
<html xmlns=""http://www.w3.org/1999/xhtml"">
<head>
<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"" />
<title>最新更新</title>
<meta name=""keywords"" content=""毛興宇最新更新"" />
<meta name=""description"" content=""毛興宇最新更新"" />
<style type=""text/css"">
 body {font-family: Verdana;FONT-SIZE: 12px;MARGIN: 0;color: #000000;background: #ffffff;}
 img {border:0;}
 li {margin-top: 8px;}
 .page {padding: 4px; border-top: 1px #EEEEEE solid}
 .author {background-color:#EEEEFF; padding: 6px; border-top: 1px #ddddee solid}
 #nav, #content, #footer {padding: 8px; border: 1px solid #EEEEEE; clear: both; width: 95%; margin: auto; margin-top: 10px;}
</style>
</head>
<body vlink=""#333333"" link=""#333333"">
<h2 style=""text-align: center; margin-top: 20px"">毛興宇最新更新 </h2>
<center></center>
<div id=""nav""><a href=""/""><strong>毛興宇最新更新</strong></a>  &raquo; <a href=""/sitemap.html"">最新更新</a></div>
<div id=""content"">
<h3>最新文章</h3>
<ul>
<?php
foreach($list as $r)
{
?>

<li><a href=""<?php echo $r['arcurl'] ?>""><?php echo $r['title'] ?></a></li>

<?php
}
?>
</ul>
</div>
<div id=""footer"">查看網站首頁: <strong><a href=""/""><strong>毛興宇最新更新</strong></a></strong></div><br />
<center>
<div style=""text-algin: center; font-size: 11px""><strong><a href=""http://blog.csdn.net/powmxypow/"" target=""_blank"">織夢管理員之家</a></strong><br /><br /></div>
</center>
</body>
</html>
發佈了140 篇原創文章 · 獲贊 46 · 訪問量 44萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章