Jump to:

23374 Posts in 18175 Topics by 2866 members

General Questions

SilverStripe Forums » General Questions » adding simple Facebook "like" button

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 3039 Views
  • scottsaz
    Avatar
    Community Member
    2 Posts

    adding simple Facebook "like" button Link to this post

    Hey there - newbie here and brand new to SS. I've already figured out how to add Paypal button functionality into my page templates, but I'm stuck on adding a simple Facebook "Like" button. I've gotten the code from Facebook and coded the page template file (Page.ss), but the button isn't showing up.

    What am I doing wrong?

    Thanks!!

    Edit: using SS 2.3.4

  • sol1
    Avatar
    Community Member
    4 Posts

    Re: adding simple Facebook "like" button Link to this post

    Would you be able to put up a sample of the code you tried to embed in the page?? This would help in diagnosing the issue.

  • scottsaz
    Avatar
    Community Member
    2 Posts

    Re: adding simple Facebook "like" button Link to this post

    Yes - here is the code:
    As per the instructions from Facebook, first added the following:

    <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/all.js#xfbml=1";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    then the rest:

    <div class="fb-like" data-href="http://www.solaceinternational.org" data-send="true" data-width="450" data-show-faces="true" data-action="recommend"></div>

    thanks for any help!

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: adding simple Facebook "like" button Link to this post

    Facebook recommends putting the <script> code in the head, so I would try that first. Then put the divs within the page body.

  • elgordo
    Avatar
    Community Member
    70 Posts

    Re: adding simple Facebook "like" button Link to this post

    hi @scottsaz

    I've created a simple Facebook module that incorporates the Like functionality into two lines of template code.

    After the body tag add this

    <% include DownloadFacebookJS %>

    Where you require the Like box, add this to your template

    <% include FacebookLikeButton %>

    The module also incorporates the option of including Facebook metadata and of displaying a Facebook LikeBox page on your website.

    For more information see Web of Talent - Facebook Module or GitHub - Gordon Anderson - Facebook Module

    Cheers

    Gordon

    3039 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.