1. 程式人生 > >織夢CMS首頁RSS訂閱源制作

織夢CMS首頁RSS訂閱源制作

... 動態 一個 view nco 織夢 點擊 模板文件 fun

默認情況下,織夢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源就會自動更新。

織夢CMS首頁RSS訂閱源制作