实现思路:
因为百度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 "<?xml version=\"1.0\" encoding=\"".$charset."\"?>\n".
"\n".
" \n".
(count($catarray) > 1 ?
"
{$_G[setting][bbname]}\n"." {$_G[siteurl]}forum.php\n".
" Latest $num articles of all categories\n"
:
"
{$_G[setting][bbname]} - $catname\n"." {$_G[siteurl]}portal.php?mod=list&catid=$rsscatid\n".
" Latest $num articles of $catname\n"
).
" Copyright(C) {$_G[setting][bbname]}\n".
" Discuz! Board by Comsenz Inc.\n".
" ".gmdate('r', TIMESTAMP)."\n".
" $ttl\n".
" \n".
" {$_G[siteurl]}static/image/common/logo_88_31.gif\n".
"
{$_G[setting][bbname]}\n"." {$_G[siteurl]}\n".
" \n";
修改为
echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?>\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".
" daily\n".
" 1.0\n".
" \n";
找到
echo " \n".
"";
修改为
echo " \n";
然后访问地址:http://www.doweb8.ccom/ portal.php?mod=sitemap即可看到效果,百度sitemap提交这个地址即可。
注意显示条数,可以修改portal_sitemap.php这里:$num = 20; 程序默认是显示20条,可根据自己的需要更改。