首页军事新闻详情

discuz教程:制作门户的百度sitemap的方法

本站原创2020-08-19 22:57:14 快审 527

实现思路:

因为百度sitemap可以提交xml文件,所以我们可以利用discus内置的rss来实现。

实现方法:

1、打开根目录的 portal.php 文件

找到

if(empty($_GET['mod']) || !in_array($_GET['mod'], array('list', 'view', 'comment', 'portalcp', 'topic', 'attachment', 'rss', 'block'))) $_GET['mod'] = 'index';

修改为

if(empty($_GET['mod']) || !in_array($_GET['mod'], array('list', 'view', 'comment', 'portalcp', 'topic', 'attachment', 'rss', 'block', 'sitemap'))) $_GET['mod'] = 'index';

2、找到 source/module/portal/portal_rss.php 文件并复制一份,命名为 portal_sitemap.php

打开 portal_sitemap.php 文件

找到

echo "n".

"n".

" n".

(count($catarray) > 1 ?

" {$_G[setting][bbname]}n".

" {$_G[siteurl]}forum.phpn".

" Latest $num articles of all categoriesn"

:

" {$_G[setting][bbname]} - $catnamen".

" {$_G[siteurl]}portal.php?mod=list&catid=$rsscatidn".

" Latest $num articles of $catnamen"

).

" Copyright(C) {$_G[setting][bbname]}n".

" Discuz! Board by Comsenz Inc.n".

" ".gmdate('r', TIMESTAMP)."n".

" $ttln".

" n".

" {$_G[siteurl]}static/image/common/logo_88_31.gifn".

" {$_G[setting][bbname]}n".

" {$_G[siteurl]}n".

" n";

修改为

echo "n".

" n";

找到

echo " n".

" ".$article['subject']."n".

" $_G[siteurl]".($rewriteflag ? rewriteoutput('portal_article', 1, '', $article[aid]) : "portal.php?mod=view&aid=$article[aid]")."n".

" n".

" ".dhtmlspecialchars($article['catname'])."n".

" ".dhtmlspecialchars($article['author'])."n".

($attachfile ? ''."n" : '').

" ".gmdate('r', $article['dateline'])."n".

" n";

修改为

echo " n".

" $_G[siteurl]".($rewriteflag ? rewriteoutput('portal_article', 1, '', $article[aid]) : "portal.php?mod=view&aid=$article[aid]")."n".

" ".date('Y-m-d', $article['dateline'])."n".

" dailyn".

" 1.0n".

" n";

找到

echo " n".

"";

修改为

echo " n";

然后访问地址即可看到效果,百度sitemap提交这个地址即可。

注意显示条数,可以修改portal_sitemap.php这里:$num = 20; 程序默认是显示20条,可根据自己的需要更改。

以上就是本文章的内容,希望对大家有所帮助


标签:
随机快审展示 刷新 快审榜
加入快审,优先展示

加入VIP

发表评论

  • * 评论内容:
  •  

精彩评论

  • 无任何评论信息!
提交站点
提交文章
提交小程序
提交公众号