请选择 进入手机版 | 继续访问电脑版

 找回密码
 立即注册
查看: 1464|回复: 0

为discuz程序制作sitemap文件每页调取100条最新帖子文章

[复制链接]

6771

主题

8

回帖

2万

积分

管理员

积分
21718
发表于 2019-5-22 19:56:47 | 显示全部楼层 |阅读模式
应用中心有不少sitemap之类的插件,有点小贵,嫌麻烦,也许没深刻体会那些插件的用处吧(*^__^*) 嘻嘻
参考网上的方法制作适合discuz的sitemap文件,每页调取100条最新帖子,希望对搜索引擎SEO有点帮助咯

具体实现代码

  1. <?php
  2. define('APPTYPEID', 4);
  3. define('CURSCRIPT', 'sitemap');
  4. require './source/class/class_core.php';
  5. $discuz = & discuz_core::instance();
  6. $discuz->cachelist = $cachelist;$discuz->init();
  7. $navtitle='免费资源网 -  免费资源分享平台 提供最新免费资源信息';    //网站名称
  8. $metakeywords='免费资源网 -  免费资源分享平台 提供最新免费资源信息';  //网站关键词
  9. $metadescription='免费资源网 -  免费资源分享平台 提供最新免费资源信息'; //网站描述
  10. include template('common/header');

  11. echo '
  12. <style type="text/css">
  13. a:link {color: #333; text-decoration: none;}
  14. a:visited {text-decoration: none; color: #666;}
  15. a:hover {text-decoration: none; color: #F90;}
  16. a:active {text-decoration: none; color: #F90;}
  17. .newtid{width:99.7%;float:left; margin-top:10px; border: 1px dotted #F90; margin-bottom:10px;}
  18. .newtid li{padding-left:2%;font-size: 12px;width:48%; float:left;line-height: 25px;}
  19. .newtid li a{color: #333;}
  20. .newtit strong a{position: absolute;bottom: 98765px;}
  21. .newtid h2{font-size: 16px;line-height: 45px;}
  22. </style>   
  23. <ul class="newtid">';
  24. $site_num  = DB::result(DB::query("SELECT COUNT(`tid`) FROM ".DB::table('forum_thread')." as a inner join ".DB::table('forum_forum')." as b on a.fid=b.fid where a.displayorder=0 ORDER BY a.tid DESC"));
  25. $site_num = $site_num ? $site_num :0;
  26. $site_listnum = 100;
  27. $site_page = intval($_G['gp_page']) ? intval($_G['gp_page']) :1;
  28. $site_max = $site_page > 0 ? $site_listnum * ($site_page-1) : 0;
  29. $site_max2 =   $site_max2 + 100;
  30. $querys = DB::query("SELECT a.tid,a.subject,a.fid,b.name FROM ".DB::table('forum_thread')." as a inner join ".DB::table('forum_forum')." as b on a.fid=b.fid where a.displayorder=0 ORDER BY a.tid DESC LIMIT ".$site_max.",".$site_max2);
  31. $multipage = multi($site_num, $site_listnum,$site_page, "sitemap.php");
  32. $i=1;while($threadfid = DB::fetch($querys)){echo '<li>'.$i.'、<em>[<a href="forum.php?mod=forumdisplay&fid='.$threadfid['fid'].'">'.$threadfid['name'].'</a>]</em> <a href="forum.php?mod=viewthread&tid='.$threadfid['tid'].'" target="_blank">'.$threadfid['subject'].'</a></li>';$i++;}
  33. echo $multipage;
  34. echo '</ul>';
  35. include template('common/footer');?>
复制代码



将上面代码保存为sitemap.php,并上传到你空间的根目录下

进入你网站的后台-界面-导航设置-底部导航,添加一个底部链接,链接地址为http://你的地址/sitemap.php,别忘了勾选“可用”即可生效
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表