dedecms系统默认不存在rss文件,而且后台提供的生成rss文件是按照栏目生成的松散的rss文件,存储路径也比较危险,默认存储在data文件夹下。那么有没有一种更好的办法输出dedecms全站的rss订阅文件呢?下面IT零五就为大家分享一种不需要修改dedecms熊文件,为dedecsm添加rss订阅功能的方法。
首先新建一个rss.php文件,复制以下代码到文件中,保存为“utf-8无BOM”格式,然后将该文件上传到网站根目录中。
<?php
SetTemplet($cfg_basedir . $cfg_templets_dir . "/default/rss.htm");
header("Content-type:application/xml");
$pv->Display();
?>
然后新建一个rss.htm文件,复制以下代码到文件中(注意将本站网址it.02405.com换成你网站的域名),保存为“utf-8无BOM”格式,然后将该文件上传到网站/templets/default目录中。
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>{dede:global.cfg_webname/}</title>
<description>{dede:global.cfg_description/}</description>
<link>{dede:global.cfg_basehost/}</link>
<language>zh-cn</language>
<generator>{dede:global.cfg_webname/}</generator>
{dede:arclist row='20' col='1' titlelen='100' orderby='pubdate'}
<item>
<link>http://it.02405.com[field:arcurl/]</link>
<title>
<![CDATA[[field:title function='html2text(@me)'/]]]>
</title>
<author>[field:writer/]</author>
<category>[field:typename/]</category>
<pubDate>[field:pubdate function='strftime("%a, %d %b %Y %H:%M:%S +0800",@me)'/]</pubDate>
<guid>http://it.02405.com[field:arcurl/]</guid>
<description>
<![CDATA[[field:description function='html2text(@me)'/] ...]]>
</description>
</item>
{/dede:arclist}</channel>
</rss>
好了,现在你可以访问你网站的域名/rss.php,你会发现dedecms全站rss订阅文件已经输出了,接下来在你的模板中正确调用rss.php文件即可。
注:这条百度经验(http://jingyan.baidu.com/article/1612d500751ce1e20e1eee24.html)中的rss.htm文件命名与rss.php文件中引用的名称不同,因此不好用。如果不知道怎么保存utf-8无BOM格式文件,请看。