最近在制作dede模板时,发现如果让新浪微博与dedecms进行关联,这样访问量就能到自己的站上来,让站上的流量到微博上去,经研究,现在公布方法。
步骤/方法
-
在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();
?> -
在dedecms的模板文件夹下(也就是/templets/default目录下新建一个rss.htm文件),其中内容如下:
<?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='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>
-
修改你的主页模板index.htm在<head>和</head>之间加入一下标记。
<link rel="alternate" type="application/rss+xml" href="http://www.pekdo.com/rss.php" title="湖北程力专用汽车有限公司" />
-
让新浪微博关联你的站.
登陆新浪微博,进入上面帐户 》我的工具 》 关联博客 》 把你的网址贴在框里 确定就OK了。
这样只要你的网站有更新并生成了主页,新浪微博就会自动更新你更新的最新的微博。
本文介绍如何通过RSS订阅的方式让DEDECMS站点与新浪微博实现自动同步更新,包括设置RSS源、修改主页模板及新浪微博的关联步骤。
1898

被折叠的 条评论
为什么被折叠?



