4
votes


I am trying to develop facebook comments application in my codeignitor project but i face problem like loading comment box and also not display all comment properly and when i use another fresh application codeignitor that works fine.

I use this code in view file

(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/en_US/all.js#xfbml=1&appId=123456789789652";
fjs.parentNode.insertBefore(js, fjs); } (document, 'script', 'facebook-jssdk'));

I use this code in controllers file

class Fb_comments extends CI_Controller { function _construct()
{ parent::
_construct();
}

  function index()
  {   

$this->load->view('fb_comments'); } }

any idea and advice will be appriciated

Thanks in advance.. bhavik patel

1
That code only loads the Facebook JavaScript SDK; you still need <fb:comments> boxes on the page to make them appear.Ja͢ck

1 Answers

1
votes

You are lacking the code that actually displays the facebook comments block:

<div class="fb-comments" data-href="http://example.com" data-num-posts="2" data-width="470"></div>

where http://example.com is to be replaced by the site url you mentioned in the facebook code generator.

http://developers.facebook.com/docs/reference/plugins/comments/

When you press "get code" you have 2 codes to include in your view, the first the the JS SDK and the second is the div where you put the content.