首頁  >  文章  >  後端開發  >  RSS全站靜態輸出和RSS訂閱的步驟(dedecms)

RSS全站靜態輸出和RSS訂閱的步驟(dedecms)

Y2J
Y2J原創
2017-04-25 15:50:082290瀏覽

在論壇上看了很多貼子,但發現還是有些人不太會用。認為說明不夠詳細,以至於不能實現!我再來和大家說一下. 首先,你新建一個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模板輸出文件,把下面的程式碼拷貝到其中: 

程式碼如下:

<?xml version="1.0" encoding="gb2312" ?> <rss version="2.0"> <channel> <title>{dede:global.cfg_webname/}</title> <link>{dede:global.cfg_basehost/}</link> <description>{dede:global.cfg_description/}</description> copyright dedecms <language>zh-cn</language> <generator>{dede:global.cfg_webname/}</generator> <webmaster>{dede:global.cfg_adminemail/}</webmaster> {dede:arclist row=&#39;60&#39; col=&#39;1&#39; titlelen=&#39;100&#39; orderby=&#39;pubdate&#39;} <item> <link>http://www.jb51.net[field:arcurl/]</link> <title><![CDATA[[field:title function=&#39;html2text(@me)&#39;/]]]></title> <author>[field:writer/]</author> <category>[field:typename/]</category> <pubDate>[field:pubdate function=&#39;strftime("%a, %d %b %Y %H:%M:%S +0800",@me)&#39;/]</pubDate> <guid>http://www.jb51.net[field:arcurl/]</guid> <description><![CDATA[[field:description function=&#39;html2text(@me)&#39;/] ... <b>文章分类</b>:[field:typename/]<a href="http://www.jb51.net[field:arcurl/]" target="_blank">阅读全文</a> | <a href="http://www.jb51.net/plus/recommend.php?aid=[field:id/]" target="_blank">邮件推荐</a> | <a href="http://www.jb51.net[field:arcurl/]" target="_blank">评论回复</a>]]></description> 织梦好,好织梦 </item> {/dede:arclist} </channel> </rss>

如果你自己的網站使用時,請把網址替換為你的網址即可。保存該檔案與index.htm主頁模板相同的目錄下,登陸管理後台,清理一下緩存,更新下html就有了
------------------- --------------------------
以上是動態輸入,要變成靜態輸出的話還要照下面說的做
--------------------------------------
第一步:開啟頻道模型下的單頁文件管理

點選增加一個頁面

按照上圖去建個這樣的單頁檔案就行了,但是名字不能用「全站RSS靜輸出」 最好使用英文名字,自已可以隨便起的,點一下保存其它的不要管它
最後更新一下緩存,最好在全站更新一下就行了
rss的訂閱我是把dede中的原文件rssmap.html 重新做了一下,然後覆蓋原始的文件原始的文件在data資料夾中
下面提供一些熱門的rss訂閱代碼供大家參考使用

<p class="indexContent"> 
<p><a href="http://www.google.com/reader/view/feed/http://www.shsui.cn/rss.xml" target="_blank" rel="nofollow"><img src="images/rss/o_sub_google.gif" style="border:0px;" alt="通过Google订阅本站" /></a></p> 
<p><a href="http://www.zhuaxia.com/add_channel.php?url=www.shsui.cn/rss.xml" target="_blank" rel="nofollow"><img src="images/o_sub_zhuaxia.gif" style="border:0px;" alt="通过抓虾订阅本站" /></a></p>

織夢內容管理系統

<p><a href="http://www.xianguo.com/subscribe.php?url=www.shsui.cn/rss.xml" target="_blank" rel="nofollow"><img src="images/rss/o_sub_xianguo.gif" style="border:0px;" alt="通过鲜果订阅本站" /></a></p> 
<p><a href="http://www.shsui.cn/rss.xml" target="_blank" rel="nofollow"><img src="images/rss/o_sub_hexun.gif" style="border:0px;" alt="通过和讯博揽订阅本站" /></a></p>
<p><a href="http://add.my.yahoo.com/rss?url=www.shsui.cn/rss.xml" target="_blank" rel="nofollow"><img src="images/rss/o_sub_myyahoo.gif" style="border:0px;" alt="通过雅虎订阅本站" /></a></p>

本文來自織夢

<p><a href="http://reader.yodao.com/#url=http://www.shsui.cn/rss.xml" target="_blank" rel="nofollow"><img src="images/rss/o_yodaoresbutton.gif" style="border:0px;" alt="通过有道订阅本站" /></a></p> 
<p><a href="http://www.bloglines.com/sub/http://www.shsui.cn/rss.xml" target="_blank" rel="nofollow"><img src="images/rss/o_sub_bloglines.gif" style="border:0px;" alt="通过BlogLines订阅本站" /></a></p> </p>

以上是RSS全站靜態輸出和RSS訂閱的步驟(dedecms)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn