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 格式文件,请看。
本文为原创文章,版权归主机之家测评所有,欢迎分享本文,转载请保留出处!