Disqus 为动态页面加载相同的评论
我有一个加载不同想法的动态页面。我使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
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 uniquedisqus_identifier
that corresponds to that idea. (It's not clear what$title
represents in your PHP script, which is what is currently being assigned todisqus_identifier
.)看起来您的标识符不够唯一,请参阅此处的参考文档:http://docs.disqus.com/ help/14/
它指出:
Looks like your identifier is not unique enough, see reference documentation here: http://docs.disqus.com/help/14/
It states:
我在使用 AJAX 通过新的 disqus 线程加载新内容的页面上遇到了同样的问题。我的解决方案是将标识符和 url 设置为相同的值。
其中 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.
where myPageID is an integer that I dynamically update using AJAX
我终于按如下方式完成了这项工作。
Ajax 站点的 Disqus doco [1] 指出,
要求
是设置变量this.page.identifier
和this.page.URL
使用full hashbang #!
令人困惑的是,上述 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 variablesthis.page.identifier
andthis.page.URL
using afull hashbang #!
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