找回密碼
 註冊
搜索
查看: 721|回復: 0

[X3.5] discuz X3.5 facebook twitter 推文插件

[複製鏈接]
發表於 2025-3-5 18:57:36 | 顯示全部樓層 |閱讀模式
 
Push to Facebook
從X3.2生到X3.5 facebook twitter 分享功能失效
於是手動自己改了


template/default/common/header_common.htm
找到

  1. <meta http-equiv="MSThemeCompatible" content="Yes" />
複製代碼
下面加上
  1. <!--{if $_G[tid]}-->
  2.         <meta property="og:type" content="article"/>
  3.         <meta property="og:site_name" content="$_G['setting']['bbname']"/>
  4.         <meta property="og:title" content="$_G[forum_thread][subject] - $_G['setting']['bbname']"/>
  5.         <meta property="og:description" content="{if !empty($metadescription)}{echo htmlspecialchars($metadescription)}{/if}"/>
  6.         <!--{if $iattrs}-->
  7.         <meta property="og:image" content="$iattrs" />
  8.         <meta property="og:image:width" content="300"/>
  9.         <link rel="image_src" href="$iattrs" />
  10.         <!--{/if}-->
  11.         <!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}-->
  12.         <meta property="og:url" content="$_G[siteurl]thread-{$_G[tid]}-1-1.html"/>
  13.         <!--{else}-->
  14.         <meta property="og:url" content="$_G[siteurl]forum.php?mod=viewthread&tid=$_G[tid]"/>
  15.         <!--{/if}-->
  16.         <meta property="fb:app_id" content="$_G['cache']['plugin']['facebook_connect']['appid']"/>
  17.         <!--{/if}-->
複製代碼


template/default/forum/viewthread_node_body.htm
找到

  1. <div class="{if !$_G[forum_thread][special]}t_fsz{else}pcbs{/if}">
  2.                 <!--{if $post['first']}-->
複製代碼
下面加上
  1. <!-- add by woff-->
  2.                 <div><!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}--><fb:like href="$_G[siteurl]thread-{$_G[tid]}-1-1.html" show_faces="false" width="450" data-layout="button_count"></fb:like><!--{else}--><fb:like href="$_G[siteurl]forum.php?mod=viewthread&tid=$_G[tid]" show_faces="false"  width="450" data-layout="button_count"></fb:like><!--{/if}--></div>
  3.                         <div>{subtemplate forum/viewthread_fb}</div>
  4.                 <!-- add by woff-->
複製代碼
新增
template/default/forum/viewthread_fb.htm
  1. <div><a href="javascript:desc='';via='';if(document.referrer)via=document.referrer;if(typeof(_ref)!='undefined')via=_ref;if(window.getSelection)desc=window.getSelection();if(document.getSelection)desc=document.getSelection();if(document.selection)desc=document.selection.createRange().text;void(open('http://www.facebook.com/share.php?u='+encodeURIComponent(location.href)));"><img src="static/image/common/facebook.png" alt="Push to Facebook" border="0" /></a>
  2. <a href="http://www.tshopping.com.tw/forum.php?mod=viewthread&tid=$thread[tid]" class=
  3. "twitter-share-button"><img src="static/image/common/twitter.png" alt="Push to Twitter" border="0" /></a>  <script>!function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https'; if (!d.getElementById(id)) { js = d.createElement(s); js.id = id; js.src = p + '://platform.twitter.com/widgets.js'; fjs.parentNode.insertBefore(js, fjs); } }(document, 'script', 'twitter-wjs');</script></div>
複製代碼


source/module/forum/forum_viewthread.php
找到

  1. $postlist[$pid]['message'] = preg_replace("/\[attach\]\d+\[\/attach\]/i", '', $postlist[$pid]['message']);
複製代碼
下面加上
  1. if($postlist[$pid]['first'] == 1) {
  2.                         $getmsgi = $postlist[$pid]['message'];
  3.                 }
  4.         }
  5.         preg_match_all('/<img.+file=[\'"]([^\'"]+)[\'"].*>/i', $getmsgi, $iattrsA);
  6.         preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $getmsgi, $iattrsB);
  7.         if($iattrsA[1][0]) {
  8.                 $iattrs = $_G[siteurl].$iattrsA[1][0];
  9.         } elseif($iattrsB[1][0]) {
  10.                 $iattrs = $iattrsB[1][0];
  11.         } else {
  12.                 $iattrs = false;
複製代碼


更新緩存

discuz facebook twitter 推文插件

discuz   facebook twitter 推文插件



完成
 
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|TShopping

GMT+8, 2025-4-30 16:46 , Processed in 0.024582 second(s), 24 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表