romain
romain

Reputation: 65

How to embed a facebook like button on every webpage of my website?

What should I put instead of: http%3A%2F%2Fexample.com%2Fpage%2Fto%2Flike in this href field so that it returns the permalink of the webpage. I want to insert the same code in every webpage of the website.

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fexample.com%2Fpage%2Fto%2Flike&amp;layout=standard&amp;show_faces=true&a
mp;  width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

Upvotes: 0

Views: 3469

Answers (3)

Thomas
Thomas

Reputation: 21

For Joomla there is a easy to use one click installable module which lets you do all the configuration and displaying of the module in your site with a user friendly environment. In this case you wont need to add each url of your site seperately. Each link in your site is detected automatically and given its own seperate like button. This is a php facebook like module.

You can find it here http://extensions.joomla.org/extensions/social-web/republish/14580 or here http://code.google.com/p/joomla-facebook-like-button-module

Upvotes: 2

Matt Huggins
Matt Huggins

Reputation: 83299

It depends on what server-side language you're using. In PHP you could do something like this, where I reference $_SERVER['REQUEST_URI']:

<?php $encodedUrl = htmlentities(urlencode($_SERVER['REQUEST_URI'])); ?>
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo $encodedUrl; ?>&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

If you're not using a server-side language, you could do it in JavaScript. This is untested, but:

<script type="text/javascript">
    var encodedUrl = escape(encodeURIComponent(window.location));
    document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=' + encodedUrl + '&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>');
</script>

Upvotes: 0

user164226
user164226

Reputation:

If, for instance, you were using ASP.NET with MasterPages, you'd put this just below the ContentPlaceHolder for your article content. Pass it some variables for the page's filename, the title of the article, etc.

Regardless of your templating model, you want the anchor to work out to something like this:


<a href="http://www.facebook.com/sharer.php?u=http://YOURPAGE.ASPX&t=TITLEOFYOURPAGE+-+YOURWEBSITENAME"><img src="http://www.facebook.com/images/connect_favicon.png" border="0" alt="Share this article on Facebook" /></a>

Upvotes: 0

Related Questions