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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

adding simple Facebook "like" button


Go to End


5 Posts   5556 Views

Avatar
scottsaz

Community Member, 2 Posts

6 February 2012 at 12:54pm

Edited: 06/02/2012 12:55pm

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

Community Member, 4 Posts

6 February 2012 at 7:40pm

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

Community Member, 2 Posts

7 February 2012 at 4:21am

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.

Community Member, 309 Posts

14 February 2012 at 10:55am

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

Community Member, 70 Posts

19 November 2012 at 6:27pm

Edited: 19/11/2012 6:27pm

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