在 Magento 中设置 Disqus Multiple Canonical URL
Set up Disqus Multiple Canonical URL in Magento
我正在尝试将 Disqus 集成到我的测试 Magento 网站上。我正在使用 NeoTheme 博客扩展,但是我禁用了内置评论部分并将其更改为 disqus。
问题出在规范 url 上。我有一个主分类http://?????.com/news-and-media/ that has a sub category /blog and /news and others. The blog page can be access as http://????/.com/news-and-media/blog-content and http://????/.com/news-and-media/blog/blog-content,两者显示相同的内容。我尝试对每个 url 发表评论,但另一页缺少评论,反之亦然。
这是我目前的进度。
我的 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
检查此 link 以供参考。 http://javascript.qahowto.com/Obtaining-canonical-url-using-JavaScript-javascript-url-5b420a
我正在尝试将 Disqus 集成到我的测试 Magento 网站上。我正在使用 NeoTheme 博客扩展,但是我禁用了内置评论部分并将其更改为 disqus。
问题出在规范 url 上。我有一个主分类http://?????.com/news-and-media/ that has a sub category /blog and /news and others. The blog page can be access as http://????/.com/news-and-media/blog-content and http://????/.com/news-and-media/blog/blog-content,两者显示相同的内容。我尝试对每个 url 发表评论,但另一页缺少评论,反之亦然。
这是我目前的进度。
我的 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
检查此 link 以供参考。 http://javascript.qahowto.com/Obtaining-canonical-url-using-JavaScript-javascript-url-5b420a