网上很多内容都是针对论坛forum板块的,但是今天我需要的是portal的,所以在进行了一番研究后,在此把discuz两种rss的输出修改都写出来
Discuz!门户和论坛rss地址和相关文件。
门户地址:你的网址/portal.php?mod=rss
论坛地址:你的网址/forum.php?mod=rss
对应的控制rss输出内容的文件为:/source/module/portal/portal_rss.php和/source/module/forum/forum_rss.php。
贴上修改后的代码
这里是forum的
if($attachfile) {
if($attachremote) {
$filename = $_G['setting']['ftp']['attachurl'].'forum/'.$attachfile;
} else {
$filename = (!strstr($_G['setting']['attachurl'], '://') ? $_G['siteurl'] : '').$_G['setting']['attachurl'].'forum/'.$attachfile;
}
}
//在这里加入数据库查询语句
$fdata = DB::fetch_first("SELECT * FROM ".DB::table('forum_post')." WHERE tid = '".$thread['tid']."' and first = 1");
echo " <item>\n".
" <title>".$thread['subject']."</title>\n".
" <link>$_G[siteurl]".($trewriteflag ? rewriteoutput('forum_viewthread', 1, '', $thread['tid']) : "forum.php?mod=viewthread&tid=$thread[tid]")."</link>\n".
// 这里是原代码 下面一行是查询到的内容 " <description><![CDATA[".dhtmlspecialchars($thread['description'])."]]></description>\n".
" <description><![CDATA[".dhtmlspecialchars($fdata['message'])."]]></description>\n".
" <category>".dhtmlspecialchars($thread['forum'])."</category>\n".
" <author>".dhtmlspecialchars($thread['author'])."</author>\n".
($attachfile ? '<enclosure url="'.$filename.'" length="'.$attachsize.'" type="image/jpeg" />' : '').
" <pubDate>".gmdate('r', $thread['dateline'])."</pubDate>\n".
" </item>\n";
这里是portal的
if($attachfile) {
if($attachremote) {
$filename = $_G['setting']['ftp']['attachurl'].'portal/'.$attachfile;
} else {
$filename = $_G['siteurl'].$_G['setting']['attachurl'].'portal/'.$attachfile;
}
}
//同理 这里是查询文章内容的数据查询
$fdata = DB::fetch_first("SELECT * FROM ".DB::table('portal_article_content')." WHERE aid = ".$article['aid']);
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".
" <description><![CDATA[".dhtmlspecialchars($fdata['content'])."]]></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";
之所以需要修改 是因为rss默认查询的是 rss缓存表 这里只存储了摘要而没有内容 然后根据aid 或者 tid 去查询相应的内容
如有问题 欢迎通过快问咨询