Search code examples
htmllocation-href

Facebook Like ( in Modal Window ) change location_href


We use PrettyPhoto and newest incarnation 3.1.3 allows users to Like and Tweet within the Modal Window..

This is great, but it doent work (fb that is ). I am yet to find anyone who has got this working, even PrettyPhoto site itself.

Anyway, I really would like to use this. The issue i think is how the url is parsed.

Prettyphoto js code for the iframe like button is..

<iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href={location_href}&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe>

The key seems to be {location_href}

IS this correct formatting ? Before you ask, yep asked on PrettyPhoto support, but alas theres a whole heap of people asking exactly the same questions with no answer.

I think the js they are using is wrong.

To add: tried parent_location_href but doesnt parse correctly, also parent.location_href and all different connotations..

Looks like I may have to put absolute link is... or should i put site url followed by location_href

Like http://mydomain.com/{location_href}


Solution

  • There is no iframe version of the like button supported by Facebook. Please see here http://developers.facebook.com/docs/reference/plugins/like/

    I would use the xfbml version and follow Tue documentation to do this by adding the namespace and asynchronously load the fb js SDK.

    Edit: here is a quick guide

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

    Alter your HTML tag to have this namespace

    <html xmlns:fb="http://ogp.me/ns/fb#">
    

    Then put your xfbml like button in modal replacing values as needed

    <fb:like href="http://yoururl.com" send="true" width="450" show_faces="true" font="arial"></fb:like>
    

    You might want to use the fb lint to help check what details are picked up by facebook and refresh any data for a url. This can be found at http://developers.facebook.com/tools/debug