[經驗]dede全站RSS訂閱靜態輸出的辦法_DedeCms教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
給大家分享一下實現DedeCMS 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();
- ?>
二、在默認模板目錄(/templetes/default)中,新增rss.html模板文件,文件代碼如下:
- XML/HTML代碼
- <?xml version="1.0" encoding="{dede:global.cfg_soft_lang /}" ?>
- <rss version="2.0">
- <channel>
- <title>RSS訂閱-{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='100' col='1' titlelen='200' 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>
三、在后臺——核心——頻道模型——單頁文檔管理,增加一個單頁面,“模板文件名”項中輸入第2步中涉及的模板文件rss.htm,而“文件名”中輸入未來Rss訂閱地址,這里我就直接生成在CMS根目錄下了。
四、更新一下緩存,并更新剛剛新增的單頁面,即可看到全站性的RSS輸出,以后很方便的就可以用各種RSS軟件去登錄Submit rss地址了。
因此,用單頁發布產品信息會很普遍,可惜的是上面談及的全站RSS靜態輸出的方法是無法提取單頁的,所以我們還需要對rss.html的模板代碼進行修改:
- XML/HTML代碼
- <?xml version="1.0" encoding="{dede:global.cfg_soft_lang /}" ?>
- <rss version="2.0">
- <channel>
- <title>RSS訂閱-{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='100' col='1' titlelen='200' orderby='pubdate'}
- <item>
- <link>http://www.wlxs.com.cn[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.***.com[field:arcurl/]</guid>
- <description><![CDATA[[field:description function='html2text(@me)'/]]]></description>
- </item>
- {/dede:arclist}
- /********調用單頁的代碼********/
- {dede:sql sql='Select * from dede_sgpage order by uptime asc limit 48'}
- <item>
- <link>http://www.***.com/[field:filename/]</link>
- <title><![CDATA[[field:title function='html2text(@me)'/]]]></title>
- <author></author>
- <category></category>
- <pubDate>[field:uptime function='strftime("%a, %d %b %Y %H:%M:%S +0800",@me)'/]</pubDate>
- <guid>http://www.***.com/[field:filename/]</guid>
- <description><![CDATA[[field:body function='html2text(@me)'/]]]></description>
- </item>
- {/dede:sql}
- /********調用單頁的代碼********/
- </channel>
- </rss>
僅供大家學習使用,希望對你有所幫助!
相關DedeCms教程:
。