【修改代码】x2 增加 微博分享 按钮 和腾讯并齐

Discuz X2官方安装包里的论坛帖子分享功能里只集成了QQ空间、腾讯微博以及腾讯朋友的功能,没有分享到新浪微博的功能,而现在用新浪微博的人不在少数,因此,我们通过修改Discuz X2代码,增加论坛帖子分享到新浪微博的功能:

修改方法一:
1、首先找到如下文件
template/default/forum/viewthread_node.htm

2、在viewthread_node.htm中找到下面代码:
  1. <div id="p_btn" class="mtw mbm cl">
  2. <!--{if !empty($_G['setting']['pluginhooks']['viewthread_share_method'])}-->
  3. <div class="tshare cl">
  4. <strong>{lang viewthread_share_to}:</strong>
复制代码
在上面代码的下面添加下面代码:
  1. <!--新浪微博代码开始-->
  2. <a style="cursor:pointer;" href="javascript:void((function(s,d,e){try{}catch(e){}var
  3. f='http://v.t.sina.com.cn/share/share.php?',u=d.location.href,p=['url=',e(u),'&title=',e
  4. (d.title),'&appkey=自己站点的key'].join('');function a(){if(!window.open([f,p].join(''),'mb',
  5. ['toolbar=0,status=0,resizable=1,width=620,height=450,left=',(s.width-620)/2,',top=',(s.height-450)/2].join('')))
  6. u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})
  7. (screen,document,encodeURIComponent));"> <img src="/xwb/images/bgimg/icon_logo.png" alt="新浪微博">新浪微博</a>
  8. <!--新浪微博代码结束-->
复制代码
3、图片地址,可下载新浪分享的小图标,保存到如下目录:static/image/common/sina.png,或者可以自己制作一个小图标。

4、保存文件并上传,这时打开一篇帖子,就会发现下面多了一个分享到“新浪微博”的功能!

效果如下:(帖子的下方多了一个分享到“新浪微博”的链接!)
附件: 您需要登录才可以下载或查看附件。没有帐号?欢迎注册