SOLVED: Add Facebook Comments To Website

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
vigor
Forum Members
Forum Members
Posts: 92
Joined: Sat Apr 25, 2009 2:32 pm

SOLVED: Add Facebook Comments To Website

Post 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
Last edited by vigor on Wed Jun 30, 2010 11:34 am, edited 1 time in total.
vigor
Forum Members
Forum Members
Posts: 92
Joined: Sat Apr 25, 2009 2:32 pm

SOLVED: Add Facebook Comments To Website

Post 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
mfal55
Forum Members
Forum Members
Posts: 131
Joined: Fri Jan 09, 2009 10:00 pm

Re: SOLVED: Add Facebook Comments To Website

Post 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?
Last edited by mfal55 on Mon Jul 26, 2010 11:02 pm, edited 1 time in total.
vigor
Forum Members
Forum Members
Posts: 92
Joined: Sat Apr 25, 2009 2:32 pm

Re: SOLVED: Add Facebook Comments To Website

Post 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.
mfal55
Forum Members
Forum Members
Posts: 131
Joined: Fri Jan 09, 2009 10:00 pm

Re: SOLVED: Add Facebook Comments To Website

Post by mfal55 »

Thanks so much Vigor!
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: SOLVED: Add Facebook Comments To Website

Post by blackhawk »

Does anyone have any recommendations on sending cmsms comments to facebook? or any social media site?

thanks!
Stringfellow
Forum Members
Forum Members
Posts: 26
Joined: Wed Mar 29, 2006 4:08 pm

Re: SOLVED: Add Facebook Comments To Website

Post 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!
User avatar
Gregor
Power Poster
Power Poster
Posts: 1874
Joined: Thu Mar 23, 2006 9:25 am

Re: SOLVED: Add Facebook Comments To Website

Post 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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: SOLVED: Add Facebook Comments To Website

Post 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...
Locked

Return to “Modules/Add-Ons”