Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

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

adding simple Facebook "like" button


Reply

5 Posts   3195 Views

Avatar
scottsaz

6 February 2012 at 12:54pm (Last edited: 6 February 2012 12:55pm), Community Member, 2 Posts

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

Avatar
sol1

6 February 2012 at 7:40pm Community Member, 4 Posts

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.

Avatar
scottsaz

7 February 2012 at 4:21am Community Member, 2 Posts

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!

Avatar
Ryan M.

14 February 2012 at 10:55am Community Member, 309 Posts

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

Avatar
elgordo

19 November 2012 at 6:27pm (Last edited: 19 November 2012 6:27pm), Community Member, 70 Posts

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 [url=http://weboftalent.asia/blog/facebook-module/]Web of Talent - Facebook Module[/url] or [url=https://github.com/gordonbanderson/weboftalent-facebook]GitHub - Gordon Anderson - Facebook Module[/url]

Cheers

Gordon