Ayush
Ayush

Reputation: 42440

FB Like box only shows on one page

I have the following code to display the FB Like box in a file called notify.html.

<div id="fb-root" class="fb_like"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<fb:like-box href="http://www.facebook.com/platform" width="270" height="250" show_faces="true" border_color="black" stream="true" header="true">
</fb:like-box>                              

This file is included in all my other pages such that everything in notify.html shows up in a sidebar for all pages.

However, the FB like box only shows up on one page,, and that happens to be the page where I also have the FB registration form.

Why does it not show up in other pages?

The FB registration code on the one page the like box shows on is

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
   FB.init({
      appId:'0000000000000', cookie:true,
      status:true, xfbml:true
   });
</script>
<fb:registration
  fields="[{'name':'name'},{'name':'emailEdu','description':'Your .edu Email','type':'text'},{'name':'captcha'}]"
  redirect-uri="http://myurlhere.com">
</fb:registration>

Upvotes: 0

Views: 1276

Answers (2)

Abby
Abby

Reputation: 3199

You need the FB.init method once on every page you want to use the api with. If you only have the code from that first example and nothing else, its not working because you haven't initialised the FB object. On the registration code you have the FB init, which is why it suddenly starts working.

Upvotes: 1

Larry K
Larry K

Reputation: 49104

Doesn't look like you're exactly copying the FB code. From their code generator on the page you referenced, you should be including the following:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like-box href="http://www.facebook.com/platform" width="292" 
show_faces="true" border_color="" stream="true" header="true"></fb:like-box>

-- but your script tag is missing the #xfbml stuff

Also use firebug or similar to see if you are getting any JS errors. Also check that you're not double loading the FB libs

Added I think the problem is that your xffbml tags are not being parsed on the other pages. Hopefully fixing the script include tag will fix it...

Upvotes: 1

Related Questions