Disqus Loading the same comments for dynamic pages

I have a dynamic page that loads different ideas. I am using disqus for the comments, but disqus keeps loading the same comments for each idea.

Here is the website. http://tech-in.org/submitted_ideas/index.php.

Here is my code

<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
     if( typeof DISQUS != 'undefined' ) { 
      DISQUS.reset({ 
        reload: true, 
         config: function () { 
           this.page.identifier = '<?php echo $title; ?>'; 
           this.page.url = 'http://tech-in.org/submitted_ideas/idea.php?id=<?php echo $idea_id; ?>'; 
         } 
       }); 
    } 
    var disqus_shortname = 'techinorg'; // required: replace example with your forum shortname
    var disqus_identifier = '<?php echo $title; ?>';
    var disqus_url = 'http://tech-in.org/submitted_ideas/idea.php?id=<?php echo $idea_id; ?>';
    var disqus_title = document.getElementById('disqus_post_title').innerHTML;
    var disqus_message = document.getElementById('disqus_post_message').innerHTML;


    /* * * 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);
    })();
</script>

Please kindly help with what is causing the error and what can i do to resolve it

Answers:

Answer

Disqus decides which comments to load based on the disqus_identifier you specify. When a different "idea" is loaded, ensure that you provide a unique disqus_identifier that corresponds to that idea. (It's not clear what $title represents in your PHP script, which is what is currently being assigned to disqus_identifier.)

Answer

Looks like your identifier is not unique enough, see reference documentation here: http://docs.disqus.com/help/14/

It states:

When Disqus-enabled pages are visited, Disqus uses this identifier to determine the appropriate comment thread to load. If the appropriate thread could not be found, a new thread is created. Disqus identifiers keep threads and pages associated.

Answer

I came across this same problem on a page that uses AJAX to load new content with a new disqus thread. The solution for me was setting both the identifier and the url equal to the same thing.

DISQUS.reset({ 
    reload: true, 
     config: function () { 
       this.page.identifier = 'http://example.com/#!' + myPageID;
       this.page.url = 'http://example.com/#!' + myPageID;
     }}); 

where myPageID is an integer that I dynamically update using AJAX

Answer

I finally got this working as follows.

The Disqus doco for Ajax sites [1], states the requirements are to set both variables this.page.identifier and this.page.URL using a full hashbang #!

var disqus_config = function () {
    this.page.identifier = window.location.origin + '/#!' + identifier 
    this.page.url = window.location.origin + '/#!' + identifier
}

Confusingly, the example recipe [2] linked in the above mentioned doco, does not do this.

References:

[1] https://help.disqus.com/customer/portal/articles/472107-using-disqus-on-ajax-sites

[2] https://github.com/disqus/DISQUS-API-Recipes/blob/master/snippets/js/disqus-reset/disqus_reset.html

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.