2010-12-08 20 views
4

私のウェブサイトのウェブページにDISQUSシステムを挿入する必要があります。それは簡単です。複数のDISQUSは同じページにありますか?

ここでの問題は、複数のDISQUSボックスを同じページに挿入する必要があることです。

私はthisのようなものが必要です。すべての記事とすべての段落には独自のコメントブロックがあります。

提案がありますか?たぶん私はAJAXを介してAPIの種類を使用してコメントを読み込む必要がありますか?

私はWordPressの電源供給されたサイトのページでこれを使用します。

+0

この解決策もうまくいくはずです:http://mystrd.at/articles/multiple-disqus-threads-on-one-page/協力サイトがなくなったようです。 – SeanJA

答えて

2

あなたがここにこのトリックを試みることができる、それは私の仕事: 残念ながら http://collaborable.com/blog/disqus-jquery-hack-awesome-ux

を、記事はvia the Wayback Machine除いて利用できなくなりました。

このリンクからの関連部分は次のとおりです。表示/コメントを非表示にするには:

<div class="comments"> 
    <p class="nocomment"> 
    <a class="nocomment" href="/">Hide comments</a> 
    </p> 
    <div class="disqus_thread"></div> 
</div> 
<p class="comment"> 
    <a class="comment" 
    href="http://collaborable.com/blog/blog-entry-title" 
    data-disqus-identifier="blog-entry-id"> 
    <span>Leave a comment</span> 
    </a> 
</p> 

...そして対応するJavascriptを:

 // DISQUS vars. 
    var disqus_shortname = 'collaborable'; 
    var disqus_identifier = ''; 
    var disqus_url = ''; 

    // Leave a comment/cancel. 
    $('.entry a.comment').click(function() { 
     // Firefox? Bad firefox. 
     if ($.browser.mozilla && window.disqus_loaded) { 
      return true; 
     } 

     // Init DISQUS. 
     disqus_identifier = $(this).data('disqus-identifier'); 
     disqus_url = $(this).attr('href'); 

     // DISQUS requires each thread to have the ID #disqus_thread. 
     $entry = $(this).parents('div.entry'); 
     $('#disqus_thread').removeAttr('id'); 
     $entry.find('div.disqus_thread').attr('id', 'disqus_thread'); 

     // Load DISQUS script, if not already loaded. 
     if ($entry.find('div.disqus_thread .dsq-reply').length == 0) { 
      $.getScript('http://' + disqus_shortname + '.disqus.com/embed.js', 
       function() { 
        window.disqus_interval = 
         setInterval('is_disqus_loaded("' + $entry.attr('id') + '")', 
          200); 
       } 
      ); 
     } 

     // Hide/kill other DISQUS forums. 
     $entry.find('a.nocomment').trigger('click'); 
     $(this).find('span').addClass('loading'); 
     return false; 

    }); 

    // Hide/kill all open DISQUS forums. 
    $('.entry a.nocomment').click(function() { 
     $('div.comments').slideUp('normal', 
      function() { 
       $(this).find('.disqus_thread').empty(); 
      }); 
     $('p.comment').slideDown(); 
     return false; 
    }); 

    function is_disqus_loaded(entry_id) { 
     $entry = $('#' + entry_id); 
     if ($entry.find('div.disqus_thread .dsq-reply').length) { 
      clearInterval(window.disqus_interval); 
      window.disqus_loaded = true; 
      $entry.find('div.comments').slideDown(); 
      $entry.find('a.comment span').removeClass('loading'); 
      $entry.find('p.comment').slideUp(); 
     } 
    } 
+3

壊れたリンク、それは何ですか? – Tom

+0

壊れたリンクx2。これは他の場所で参照されていますか? – canacast

1

あなたはhttp://tsi.github.io/inlineDisqussions/
を試みることそれはあなたのディスカスによって供給ごとの段落コメントスレッドを与えるだろう。
スクリプトとスタイルシートをダウンロードして(jQueryの後に)含めてください。
そして、このようなスクリプトを呼び出します。

<script> 
    disqus_shortname = 'your_disqus_shortname'; 
    jQuery(document).ready(function() { 
    jQuery("p").inlineDisqussions(); 
    }); 
</script> 

は、詳細はリンク先のページを参照してください。
免責事項:私はこれを書いています。

関連する問題