实现思路: 因为百度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". "<rss version=\"2.0\">\n". " <channel>\n". (count($catarray) > 1 ? " <title>{$_G[setting][bbname]}</title>\n". " <link>{$_G[siteurl]}forum.php</link>\n". " <description>Latest $num articles of all categories</description>\n" : " <title>{$_G[setting][bbname]} - $catname</title>\n". " <link>{$_G[siteurl]}portal.php?mod=list&catid=$rsscatid</link>\n". " <description>Latest $num articles of $catname</description>\n" ). " <copyright>Copyright(C) {$_G[setting][bbname]}</copyright>\n". " <generator>Discuz! Board by Comsenz Inc.</generator>\n". " <lastBuildDate>".gmdate('r', TIMESTAMP)."</lastBuildDate>\n". " <ttl>$ttl</ttl>\n". " <image>\n". " <url>{$_G[siteurl]}static/image/common/logo_88_31.gif</url>\n". " <title>{$_G[setting][bbname]}</title>\n". " <link>{$_G[siteurl]}</link>\n". " </image>\n"; 修改为 echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?>\n". " <urlset>\n"; 找到 echo " <item>\n". " <title>".$article['subject']."</title>\n". " <link>$_G[siteurl]".($rewriteflag ? rewriteoutput('portal_article', 1, '', $article[aid]) : "portal.php?mod=view&aid=$article[aid]")."</link>\n". " <description><![CDATA[".dhtmlspecialchars($article['description'])."]]></description>\n". " <category>".dhtmlspecialchars($article['catname'])."</category>\n". " <author>".dhtmlspecialchars($article['author'])."</author>\n". ($attachfile ? '<enclosure url="'.$filename.'" length="'.$attachsize.'" type="image/jpeg" />'."\n" : ''). " <pubDate>".gmdate('r', $article['dateline'])."</pubDate>\n". " </item>\n"; 修改为 echo " <url>\n". " <loc>$_G[siteurl]".($rewriteflag ? rewriteoutput('portal_article', 1, '', $article[aid]) : "portal.php?mod=view&aid=$article[aid]")."</loc>\n". " <lastmod>".date('Y-m-d', $article['dateline'])."</lastmod>\n". " <changefreq>daily</changefreq>\n". " <priority>1.0</priority>\n". " </url>\n"; 找到 echo " </channel>\n". "</rss>"; 修改为 echo " </urlset>\n";
|
手机版|笑鹰技术博客 ( 闽ICP备17023750号-1 )
GMT+8, 2025-1-18 12:57 , Processed in 0.227712 second(s), 14 queries , Gzip On.
Powered by Discuz! X3.5
Copyright © 2001-2020, Tencent Cloud.