动态获取织梦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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章