Cargo home Twitter Devlog

Adding a Facebook Like button

Last Updated: Apr 21, 2015 02:43PM PDT
You can use this Facebook form to generate an iframed button for your website, or for a specific page/project in your website:

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

Start at the top of the above page:
  • If you want a smaller button that only displays the count (which is more easily centered and formatted), choose button_count for the layout style, and uncheck "Show Friends' Faces".
     
  • Click the “Get Code” button under the preview to display a dialogue box with your Like button code.

The code generated should be in two sections, like this:

Section 1:
<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_US/sdk.js#xfbml=1&version=v2.3";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


Section 2:
<div class="fb-like" data-href="http://cargocollective.com/" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>


The block of code in Section 1 goes into your Custom HTML area . After placing that script in your Custom HTML, place this script as well:

<script>
window.fbAsyncInit = function() {   
    if(typeof Cargo.Helper == "object") {
        Cargo.Event.on("project_load_complete", function(pid) {
            FB.XFBML.parse();        
        });
    } else {
        $(document).bind("projectReady", function(e, pid){
            FB.XFBML.parse();        
        });
    }
}
</script> 


The block of code in Section 2 goes into the "contents & layout" area of any page or project where you'd like to place the Like button.

tickets@cargocollective.com
http://assets0.desk.com/
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
Invalid characters found
/customer/en/portal/articles/autocomplete