为网站添加RSS订阅能够很好的提高网站与用户的粘度,特别是对于一些博客、资讯类网站来说,RSS显得尤为重要,有的甚至将订阅数的多少看做网站质量的一个评判标准。所以,今天就是分享下如何为dedecms添加RSS订阅。方法很简单:、
1、将下面的代码以rss.php的文件保存,传至根目录。
|
rss.php:
<?php require_once (dirname(__FILE__) . "/include/common.inc.php"); require_once DEDEINC."/arc.partview.class.php"; $pv = new PartView(); $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/default/rss.htm"); header("Content-type:application/xml"); $pv->Display(); ?>
|
2、将下面的内容存为rss.htm,传至模板根目录default下。
|
rss.htm:
<?xml version="1.0" encoding="utf-8" ?> <rss version="2.0"> <channel> <title>{dede:global.cfg_webname/}</title> <link>{dede:global.cfg_basehost/}</link> <description>{dede:global.cfg_description/}</description> <language>zh-cn</language> <generator>{dede:global.cfg_webname/}</generator> <webmaster>{dede:global.cfg_adminemail/}</webmaster> {dede:arclist row='20' col='1' titlelen='100' orderby='pubdate'} <item> <link>http://www.lxvoip.net[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://www.lxvoip.net[field:arcurl/]</guid> <description><![CDATA[[field:description function='html2text(@me)'/] ... ]]></description> </item> {/dede:arclist} </channel> </rss>
|
PS:注意将上面的www.lxvoip.net换为自己的网址。
更新下网站,你的网站RSS就是http://你的网站名字/rss.php。
----------------------------------------------------------------------------------------------------------------------
相关下载 凌霄沐雪个人主站 www.cmx8.cn

没有附件