Page 1 of 1

SOLVED: Add Facebook Comments To Website

Posted: Sat Jun 26, 2010 10:46 am
by vigor
Currently trying to add facebook comments to a website and cant get it to work properly. I want to have it on multiple pages of my site but each page will have individual comments. When I insert the code below it works but any comments that are entered will be displayed on all pages as it recognises every page as been the same due to the static id of 12345. I've tried loads of different combinations to give me a dynamic id such as the {"$page_alias"} or {title} but when I add these in as the ids the comments box doesn't appear on any of the pages. The title tag wont work as I found out the id cant have any spaces and my titles will all haves spaces. I thought the best way would be to have the alias tag as the unique id, can anyone please help.

Code: Select all

<fb:comments xid="12345"></fb:comments>
The code that works for a WP blog is:

Code: Select all

<fb:comments xid="<? php page_alias() ;?>"></fb:comments>
Any help greatly appreciated,
Thanks,
Paul

SOLVED: Add Facebook Comments To Website

Posted: Wed Jun 30, 2010 11:33 am
by vigor
Thanks for the reply. Got it working in the end. I was doing something stupid. I had {literal} tags around the facebook code which meant that the alias tag call couldn't be executed.

Thanks,
Paul

Re: SOLVED: Add Facebook Comments To Website

Posted: Mon Jul 26, 2010 10:44 pm
by mfal55
Hey Vigor -
Would you mind sharing what you did to set this up?  I'm trying to tie this into each of my news details.  I'm running into the same problem on finding the unique id of the news item.  Page alias just gives me the news page that the posts live on.  Using title creates spaces, so the link fails.  Any thoughts?

Re: SOLVED: Add Facebook Comments To Website

Posted: Thu Jul 29, 2010 8:41 am
by vigor
Sorry just seen your question. Below is how I integrated the comments.

First set up your application through facebook to generate the code you need. 

The code below goes into your header

Code: Select all

<__html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml" >
The part below goes in where you want the comments box to appear

Code: Select all

<fb:comments xid="{$page_alias}"></fb:comments>

Finally the code below goes in just above the tag in your html. Note you need to put in your own appID here that facebook will give you.

Code: Select all

{literal}
<div id="fb-root"></div>
<__script__>
  window.fbAsyncInit = function() {
    FB.init({appId: 'put your own appId here', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</__script>
{/literal}
Hope this helps.

Re: SOLVED: Add Facebook Comments To Website

Posted: Thu Jul 29, 2010 11:29 am
by mfal55
Thanks so much Vigor!

Re: SOLVED: Add Facebook Comments To Website

Posted: Mon Sep 13, 2010 10:25 pm
by blackhawk
Does anyone have any recommendations on sending cmsms comments to facebook? or any social media site?

thanks!

Re: SOLVED: Add Facebook Comments To Website

Posted: Thu Dec 02, 2010 2:36 pm
by Stringfellow
If you want to use this in news (every news article should have it's own comments) I used this code:

Code: Select all

<fb:comments xid="{$entry->id}" width="490"></fb:comments>
The problem for me was that page_alias is the same on every news item. And Facebook "xid" cant handle spaces so you can't use the news title.. But the ID works like a charm!

Re: SOLVED: Add Facebook Comments To Website

Posted: Sun Feb 19, 2012 8:21 am
by Gregor
Just out of curiosity, why not taken the CGFBApp? Read from the help that the following code would give you the option you'd like

Code: Select all

{cgfb_init}{cgfb_comments}
Gregor

Re: SOLVED: Add Facebook Comments To Website

Posted: Sun Feb 19, 2012 7:14 pm
by Dr.CSS
Most times they come from a not so good XML export, try Module manager and if that fails try the tar.gz/zip file...