Disqus 为动态页面加载相同的评论

发布于 2024-12-27 23:48:36 字数 1498 浏览 4 评论 0原文

我有一个加载不同想法的动态页面。我使用 disqus 来发表评论,但 disqus 会不断为每个想法加载相同的评论。

这是网站。 http://tech-in.org/subscribed_ideas/index.php

这是我的代码

<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>

请帮助解决导致错误的原因以及我能做些什么来解决它

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

撩人痒 2025-01-03 23:48:36

Disqus 根据您指定的 disqus_identifier 决定加载哪些评论。加载不同的“想法”时,请确保提供与该想法相对应的唯一 disqus_identifier。 (尚不清楚 $title 在 PHP 脚本中代表什么,而这正是当前分配给 disqus_identifier 的内容。)

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.)

一百个冬季 2025-01-03 23:48:36

看起来您的标识符不够唯一,请参阅此处的参考文档:http://docs.disqus.com/ help/14/

它指出:

当访问启用 Disqus 的页面时,Disqus 使用此标识符来
确定要加载的适当评论线程。如果合适的话
找不到线程,创建一个新线程。 Disqus 标识符
保持线程和页面关联。

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.

烟酉 2025-01-03 23:48:36

我在使用 AJAX 通过新的 disqus 线程加载新内容的页面上遇到了同样的问题。我的解决方案是将标识符和 url 设置为相同的值。

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

其中 myPageID 是我使用 AJAX 动态更新的整数

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

风和你 2025-01-03 23:48:36

我终于按如下方式完成了这项工作。

Ajax 站点的 Disqus doco [1] 指出,要求 是设置变量 this.page.identifierthis.page.URL使用 full hashbang #!

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

令人困惑的是,上述 doco 中链接的示例 recipe [2] 并没有这样做。

参考文献:

[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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文