织梦DEDECMS教程:添加RSS订阅功能


织梦DEDECMS教程:添加RSS订阅功能 。

小编安装好 织梦dedecms 后,点击左上角的 rss 功能,发现404错误,进入后台目录一看,发现 rss 文件根本不存在,所以我们要自己给 织梦dedecms 添加 rss 订阅功能。

    新建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();  ?>   新建rss.htm传至/templates/default目录下: <?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>[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>[field:arcurl/]</guid>  <description><![CDATA[[field:description function=’html2text(@me)’/]…]]></description>  </item>  {/dede:arclist}  </channel>  </rss>   把域名改成你的域名,另外在后台 -> 模板管理 -> head.htm 里面修改rss链接为:http://域名/rss.php。

    到此,我们就实现了DEDECMS RSS订阅的功能了。这里小编提醒站长,一个良好的网站应该有订阅的功能,RSS订阅或者邮件订阅都是一个不错的选择,不仅可以增强用户体验,而且对网站的结构也很有好处。