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, Ed, biapar, Willr, Ingo, swaiba

adding simple Facebook "like" button

Go to End

5 Posts   4531 Views


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 (, but the button isn't showing up.

What am I doing wrong?


Edit: using SS 2.3.4


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.


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

then the rest:

<div class="fb-like" data-href="" data-send="true" data-width="450" data-show-faces="true" data-action="recommend"></div>

thanks for any help!

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.


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