Facebook 讚好/Like 後才可查看 Discuz 中的隱藏貼子


如題..只測試了 Discuz 7.2 版本.其他的都沒測試.
相信新的 DiscuzX 1.5 應該不支援..因為問的人是在 7.x 發問.
只是作出了簡單的修改.沒有進一步深入.發生了問題不負責..

更新:
2011-03-15 11:18PM
加入了對 Facebook 登入後可查看貼子的功能
發佈於 這裡

  1. 打開 templates/default/template.lang.php

    1
    2
    3
    4
    找到
    'post_hide_reply_hidden' => '本帖隱藏的內容需要回復才可以瀏覽',
    改為
    'post_hide_reply_hidden' => '本帖隱藏的內容需要回復才可以瀏覽 或 讚好此文章',
  2. 打開 include/discuzcode.func.php

    1
    2
    3
    4
    找到 
    if($GLOBALS['authorreplyexist']) {
    改為
    if($GLOBALS['authorreplyexist'] || (isset($_GET['show']) && $_GET['show'] == "true")) {
  3. 打開 templates/default/discuzcode.htm

    1
    2
    3
    4
    5
    6
    7
    找到
    <!--{block return}--><div class="locked">{lang post_hide_reply_hidden}</div><!--{/block}-->
    改為

    <!--{block return}-->
    <div class="locked clearfix"><div>{lang post_hide_reply_hidden}</div><fb:like colorscheme="light" show_faces="true" layout="standard" width="500"></fb:like></div>
    <!--{/block}-->
  4. 打開 templates/default/header.htm

    1
    2
    3
    4
    5
       找到
    <html xmlns="http://www.w3.org/1999/xhtml">
    改為
    </html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/xfbml">
    </html>
    1
    2
    3
    4
    找到
    tid = parseInt('$tid')
    改為
    tid = parseInt('$tid'), firstpid = parseInt('$firstpid');
    1
    2
    3
    4
    5
    找到
    <div id="append_parent"></div><div id="ajaxwaitid"></div>
    改為
    <div id="append_parent"></div><div id="ajaxwaitid"></div>
    <div id="fb-root"></div>
  5. 打開 templates/default/footer.htm

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    找到
    {eval updatesession();}


    下面加入
    <script language="javascript" type="text/javascript">
    window.fbAsyncInit = function() {
    FB.init({
    appId: '[應用程式的 App ID]',
    status: true,
    cookie: true,
    xfbml: true
    });

    FB.Event.subscribe('edge.create', function(href){
    if(typeof(firstpid)== "number") {
    ajaxget('viewthread.php?show=true&tid=' + tid + '&viewpid=' + firstpid, 'post_' + pid);
    }
    }
    });

    (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol + '//connect.facebook.net/zh_HK/all.js';
    document.getElementById('fb-root').appendChild(e);
    }());
    </script>