從X3.2生到X3.5 facebook twitter 分享功能失效
於是手動自己改了
template/default/common/header_common.htm
找到
- <meta http-equiv="MSThemeCompatible" content="Yes" />
複製代碼 下面加上
- <!--{if $_G[tid]}-->
- <meta property="og:type" content="article"/>
- <meta property="og:site_name" content="$_G['setting']['bbname']"/>
- <meta property="og:title" content="$_G[forum_thread][subject] - $_G['setting']['bbname']"/>
- <meta property="og:description" content="{if !empty($metadescription)}{echo htmlspecialchars($metadescription)}{/if}"/>
- <!--{if $iattrs}-->
- <meta property="og:image" content="$iattrs" />
- <meta property="og:image:width" content="300"/>
- <link rel="image_src" href="$iattrs" />
- <!--{/if}-->
- <!--{if in_array('forum_viewthread', $_G['setting']['rewritestatus'])}-->
- <meta property="og:url" content="$_G[siteurl]thread-{$_G[tid]}-1-1.html"/>
- <!--{else}-->
- <meta property="og:url" content="$_G[siteurl]forum.php?mod=viewthread&tid=$_G[tid]"/>
- <!--{/if}-->
- <meta property="fb:app_id" content="$_G['cache']['plugin']['facebook_connect']['appid']"/>
- <!--{/if}-->
複製代碼
template/default/forum/viewthread_node_body.htm
找到
- <div class="{if !$_G[forum_thread][special]}t_fsz{else}pcbs{/if}">
- <!--{if $post['first']}-->
複製代碼 下面加上
- <!-- add by woff-->
- <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>
- <div>{subtemplate forum/viewthread_fb}</div>
- <!-- add by woff-->
複製代碼 新增
template/default/forum/viewthread_fb.htm
- <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>
- <a href="http://www.tshopping.com.tw/forum.php?mod=viewthread&tid=$thread[tid]" class=
- "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
找到
- $postlist[$pid]['message'] = preg_replace("/\[attach\]\d+\[\/attach\]/i", '', $postlist[$pid]['message']);
複製代碼 下面加上
- if($postlist[$pid]['first'] == 1) {
- $getmsgi = $postlist[$pid]['message'];
- }
- }
- preg_match_all('/<img.+file=[\'"]([^\'"]+)[\'"].*>/i', $getmsgi, $iattrsA);
- preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $getmsgi, $iattrsB);
- if($iattrsA[1][0]) {
- $iattrs = $_G[siteurl].$iattrsA[1][0];
- } elseif($iattrsB[1][0]) {
- $iattrs = $iattrsB[1][0];
- } else {
- $iattrs = false;
複製代碼
更新緩存
discuz facebook twitter 推文插件
完成 |