2

EDIT: I would clarify that this only affects Chrome, works in IE\Firefox\Opera.

I am using the following code after the opening <body> tag

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/fi_FI/all.js#xfbml=1&appId=409074972499544";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Then in my module I've created a block for the FB Comments, so that I can add it via Panels to the pages I'd like commenting to be enabled in like this (omitting the typical block code required):

function _fb_comment() {
  $url = "http://" . $_SERVER['HTTP_HOST'] . request_uri();     
  $comment = '<div style="text-align: left !important;" class="fb-comments" data-href="' . $url . '" width="720" data-num-posts="10" colorscheme="light"></div>';    
  return $comment;
}

Visitors on my site are able to see the Comment widget, but for logged in users it's not visible and I just can't determine why. It feels like FB is hiding the widget due some problem, but there are no errors in the Console to help debug the issue. Inspecting the actual dom shows us that when it works, the markup is following (visitor):

<div style=​"text-align:​ left !important;​" class=​"fb-comments fb_iframe_widget" data-href=​"http:​/​/​url-to-the-current-page-here.com" width=​"720" data-num-posts=​"10" colorscheme=​"light" fb-xfbml-state=​"rendered">
  <span style=​"height:​ 160px;​ width:​ 760px;​">​…​</span>​
</div>

And for logged in users it shows up like this:

<div style=​"text-align:​ left !important;​" class=​"fb-comments fb_iframe_widget" data-href=​"http:​/​/​url-to-the-current-page-here.com" width=​"720" data-num-posts=​"10" colorscheme=​"light" fb-xfbml-state=​"rendered">​
  <span style=​"height:​ 0px;​ width:​ 0px;​">​…​</span>​
</div>

As we can see, FB for a reason or another decides to hide the widget -- what causes this I have no idea, I have tested disabling contextual filters so as not to fiddle with the markup of the block in any way and not aggregating JS, not caching blocks and just about everything.

As we traverse further down to INSIDE the Facebook iframe, the logged in users one has

<html lang="en" id="facebook" class="no_js">..</html>

This might be key, but I've not the slightest clue what may cause it. Was hesitating over asking this in StackOverflow instead of Drupal, but since it's a problem with being logged into Drupal, I might not be the first one to tackle the issue.

1

This bug, in the end, was a MODERATOR specific bug in the Facebook Commenting widget itself. FB has now fixed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.