Multiple disqus threads on single page

992 views
Skip to first unread message

alphawo...@gmail.com

unread,
May 19, 2014, 12:36:27 PM5/19/14
to disqu...@googlegroups.com
1. i want to have 10+ disqus comment boxes on a single page.
2. I have a comment image/logo which when clicked should pop up a lightbox/window in which Disqus comments are loaded OR in an iframe on right side of the website where comments are loaded.
3. Each time new/any other comment logo is clicked, new comments for that section loads.

How to do it ? I am a newbie. Kindly provide me code step by step. thanks.

Burak Yiğit Kaya

unread,
May 21, 2014, 12:38:37 PM5/21/14
to disqu...@googlegroups.com
Hi there,

This would be a quite advanced usage of Disqus. If you are not comfortable writing your own JavaScript I'd say this is not a good challenge to take on.


--
You received this message because you are subscribed to the Google Groups "Disqus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to disqus-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
BYK

Patrick Wynne

unread,
Sep 24, 2014, 10:09:15 AM9/24/14
to disqu...@googlegroups.com
This is old, but here is an answer with code

  1. make a js file
  2. set your shortname 
  3. set initial identifier
  4. set initial url
  5. optional language
var disqus_shortname = 'myexample';
var disqus_identifier = 1;
var disqus_url = 1;
var disqus_config = function () {
    this.language = "en";
};
var disqusElem = document.createElement("div");
disqusElem.setAttribute("id", "disqus_thread");
disqusElem.setAttribute("class", "disqus_thread");
$('body').append(disqusElem);

/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
   var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
   dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
   (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
$(disqusElem).hide();

/* * * Disqus Reset Function * * */
var reset = function (obj, e, newIdentifier, newUrl, newTitle) {    
   e.preventDefault();
   var placeholder = $('.thread-wrapper-' + newIdentifier);
   if (!placeholder.exists()) {
       var disqusPlace = document.createElement("div");
       disqusPlace.setAttribute("class", "thread-wrapper-" + newIdentifier);
       $(obj).append(disqusPlace);
   } else {
       if ($('.thread-wrapper-' + newIdentifier).html() !== '') {
           $('.thread-wrapper-' + newIdentifier).empty();
       } else {

        }
   }
   if ($('.thread-wrapper-' + newIdentifier).html() !== '') {
       $('.thread-wrapper-' + newIdentifier).empty();
   } else {
       $('.thread-wrapper-1, .thread-wrapper-2, .thread-wrapper-3').each(function () {
           $(this).empty();
       });
       $('.thread-wrapper-' + newIdentifier).attr('id', 'disqus_thread');
       var dObj = $('.disqus_thread').attr("id", "");

        if ($('.thread-wrapper-' + newIdentifier).html() !== '') {
           console.log('not empty');
       }
       DISQUS.reset({
           reload: true,
           config: function () {
               this.page.identifier = newIdentifier;
               this.page.url = newUrl;
               this.page.title = newTitle;
           }
       });
       $('.thread-wrapper-' + newIdentifier).attr('id', '');
       $('.disqus_thread').attr("id", "disqus_thread");
   }
};
jQuery.fn.exists = function () { return this.length > 0; }

usage
  1. tell it where to load the disqus example: '.thumbnail:eq(1)'
  2. event
  3. identifier
  4. url
  5. title
I just used the same number for the example
<a href="#" onclick="reset('.thumbnail:eq(1)', event, 2, 2, 2)" class="btn btn-warning" role="button">Comments</a>

This will create the elements you need for disqus and clears out the disqus when it is not actually being used.
This gives the appearance of it being opened and closed.


Burak Yiğit Kaya

unread,
Sep 24, 2014, 1:09:33 PM9/24/14
to disqu...@googlegroups.com
You don't need to do any of this. The DISQUS.reset call with our universal code is enough really.

--
You received this message because you are subscribed to the Google Groups "Disqus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to disqus-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
BYK

Burak Yiğit Kaya

unread,
Sep 24, 2014, 1:13:46 PM9/24/14
to disqu...@googlegroups.com
Oh, I also realized that your code does not actually solve his problem. He wants 10+ comment boxes at the same time.
To unsubscribe from this group and stop receiving emails from it, send an email to disqus-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
BYK

Patrick Wynne

unread,
Sep 26, 2014, 6:40:50 AM9/26/14
to disqu...@googlegroups.com
I tried that, i run into an issue with the element with id disqus thread. Oh well, this worked for my project which only needed to show it once at a time but available many times on a page.

Patrick Wynne

unread,
Sep 26, 2014, 6:47:52 AM9/26/14
to disqu...@googlegroups.com
I think i could tweak it some more and get that result actually. Maybe could just move the disqus thread through each one as it loads, continue cycling the thread to update and assign the active thread to the one the user is on to allow push/ login etc.

Is there a simpler solution?

Burak Yiğit Kaya

unread,
Sep 26, 2014, 8:03:08 AM9/26/14
to disqu...@googlegroups.com
The architecture of the app does not allow multiple widgets per page automatically. You'd need to use the internal constructor we use for each one which would be using an unsupported API (we don't guarantee that the interface won't change in the future).

This might be what you are looking for: http://tsi.github.io/inlineDisqussions/

On Fri, Sep 26, 2014 at 1:47 PM, Patrick Wynne <emasst...@gmail.com> wrote:
I think i could tweak it some more and get that result actually.  Maybe could just move the disqus thread through each one as it loads, continue cycling the thread to update and assign the active thread to the one the user is on to allow push/ login etc.

Is there a simpler solution?
--
You received this message because you are subscribed to the Google Groups "Disqus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to disqus-dev+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
BYK
Reply all
Reply to author
Forward
0 new messages