织梦CMS首页RSS订阅源制作

默认情况下,织梦CMS的RSS订阅源是根据分类订阅不同栏目的RSS。如果想订阅整站的RSS就有点困难。

解决办法:

1,添加一个RSS模板,新建名为:rss_index.htm整站RSS模板文件并保存到/templets/plus/目录下。

文件内容为:

<?xml version="1.0" encoding="{dede:global.cfg_soft_lang /}" ?>
<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='50' orderby='pubdate' titlelen='200'}
<item>
<title><![CDATA[[field:title/]]]></title>
<link>[field:arcurl/]</link>
<category>[field:typename/]</category>
<pubdate>[field:pubdate function='strftime("%a,%d%b%Y%H:%M:%S +0800",@me)'/]</pubdate>
<description><![CDATA[[field:description function='html2text(@me)'/] ... ]]></description>
</item>
{/dede:arclist}
</channel>
</rss>

2,在根目录中新建文件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 . "/plus/rss_index.htm");
header("Content-type:application/xml");
$pv->Display();
?>

3,在织梦CMS模板文件head.htm的头部标签<head> 中添加link属性。

代码如下:

<link rel=”alternate” type=”application/rss+xml” title=”网投之家” href=”http://www.bbinhome.com/rss.php“ />

重新生成静态文件后,点击浏览器上的RSS源识别按钮即可识别RSS源文件。或者在网页其它地方添加A标签形式的RSS订阅链接(例:<a href="http://www.bbinhome.com/rss.php" title="RSS订阅" ><span>RSS订阅</span></a>)。 RSS源是动态文件,不需要手动更新。默认情况调用50个最新文章,只要发表新文章,RSS源就会自动更新。

posted @ 2019-02-19 17:35  大赢家分享  阅读(133)  评论(0编辑  收藏  举报