gpt4 book ai didi

javascript - 在 Magento 中设置 Disqus 多个规范 URL

转载 作者:行者123 更新时间:2023-12-03 03:54:12 26 4
gpt4 key购买 nike

我正在尝试将 Disqus 集成到我的测试 Magento 网站上。我正在使用 NeoTheme 博客扩展,但是我禁用了内置评论部分并将其更改为 disqus。

问题出在规范网址上。我有一个主类别http://?????.com/news-and-media/它有一个子类别/博客和/新闻等。博客页面可以通过 http://????/.com/news-and-media/blog-content 访问和 http://????/.com/news-and-media/blog/blog-content ,两者显示相同的内容。我尝试对每个网址发表评论,但其他页面缺少评论,反之亦然。

这是我迄今为止的进展。

我的phtml

<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = 'http://?????.com/news-and-media/';
this.page.identifier = 'blog';
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://????-com.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

我的local.xml

<neotheme_blog_post_index>
<reference name="disquscomment">
<block type="core/template" name="dcomment" template="disqus-comments.phtml" />
</reference>
</neotheme_blog_post_index>

你有这个规范的解决方案吗?我似乎无法理解文档和示例。

https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables

How to make Disqus to work with url routing?

最佳答案

您必须使用 JavaScript 获取 rel 规范值并将其用作页面标识符。我不确定这是否有效。

var canonical = "";
var links = document.getElementsByTagName("link");
for (var i = 0; i < links.length; i ++) {
if (links[i].getAttribute("rel") === "canonical") {
canonical = links[i].getAttribute("href")
}
}
var disqus_config = function () {
this.page.url = '';
this.page.identifier = canonical;
};
(function() { // DON'T EDIT BELOW THIS LINE

检查此链接以供引用。 http://javascript.qahowto.com/Obtaining-canonical-url-using-JavaScript-javascript-url-5b420a

关于javascript - 在 Magento 中设置 Disqus 多个规范 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45026925/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com