How to disable Facebook Comments from showing up on Blog Home Page and Category Pages?
I'm currently working with Facebook Comments on a Squarespace.com website. Squarespace gives us the ability to add HTML code blocks, so implementing the code for FB Comments is easy.
The problem is Squarespace displays this code on the Blog Home Page and Category/Tag Pages, as well as the Full Blog Post. I only want the Comments to appear on the Full Blog Post.
I can use the following code to tell Squarespace to look for the Post's PERMALINK and display only when on that page, but the Script no longer works with Facebook's Comments (it used to).
Works:
<script type="text/javascript">
<!--
var docURL = document.URL;
if (docURL == "%PERMALINK%")
{
document.write('<p>This is test text.</p>');
}
-->
</script>
Does Not Work:
<script type="text/javascript">
<!--
var docURL = document.URL;
if (docURL == "%PERMALINK%")
{
document.write('<div id="fb-root"></div>
<sc'+'ript>(function(d, s, id) {
var js, fjs = d.getElementsByTagName开发者_JS百科(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#appId=153773241379548&xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</sc'+'ript>
<div class="fb-like" data-href="%PERMALINK%" data-send="false" data-layout="button_count" data-width="200" data-show-faces="false"></div>');
}
-->
</script>
Using the Facebook code, nothing shows up at all. Thanks for your help!
Try this:
<script type="text/javascript">
document.getElementsByTagName("HTML")[0].setAttribute("xmlns:fb", "http://www.facebook.com/2008/fbml");
</script>
You need to place this before the javascript that loads the facebook stuff.
Since you define where the cross domain document is located you don't have to load into root. Just supply the path info for wherever you place the cross domain file
This question was only relevant to the Squarespace Version 5 system. Since Squarespace Version 6/7, Facebook Comments can now be implemented seamlessly by using the Squarespace Developer Platform.
To display Facebook Comments on a blog post page itself, but not the blog index, you'll want to place the Facebook markup into your blog.item template file and do not place it anywhere else.
精彩评论