2017-07-11 13 views
0

Magentoのテスト用ウェブサイトにDisqusを統合しようとしています。私はNeoTheme Blog Extensionを使用していますが、ビルドインコメントセクションを無効にしてdisqusに変更します。MagentoでDisqus複数の標準URLを設定する

問題は正規のURLでした。メインカテゴリhttp://?????.com/news-and-media/には、サブカテゴリー/ブログ、/ newsなどがあります。ブログページにはhttp://????/.com/news-and-media/blog-contenthttp://????/.com/news-and-media/blog/blog-contentという2つのアクセス権があり、どちらも同じ内容を表示します。私は各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> 

あなたはこの正規のためのソリューションを持っていますか?私は、ドキュメンテーションと例を望ましくないように思えませんでした。 JavaScriptを使用してのrel正規の値を取得し、あなたのページ識別子としてそれを使用する必要が

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

How to make Disqus to work with url routing?

+0

カノニカルをバックエンドに設定しましたか? – Tyler

+0

はい、私は手動でデザインレイアウトxmlに追加します。 – rodge

答えて

1

。これがうまくいくかどうかはわかりません。

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

関連する問題