Facebook Like Utility
Easily add a Facebook Like Button with this utility
Browse
Description
Have you wanted to added a Facebook Like Button to your site? Here's a basic utility allowing you to do that easily.
Basic usage:
Import this utility to your existing xslt template and then call the template like so...
<xsl:call-template name="facebook-like">
<xsl:with-param name="url-to-like" select="'http://site.com'"/>
</xsl:call-template>
The "url-to-like" parameter is required, other than that you can customize your output with the other optional parameters. The Facebook Like Reference will explain those optional parameters are.
View this gist.
IMPORTANT NOTE: (from mqchen) Just a tip; I think you need to add two namespaces in the html tag for it to work in some IE versions. xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"
XSLT
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#" exclude-result-prefixes="fb og" version="1.0"> <!-- Name: Facebook Like Utility Version: 1.0.1 Author: Brian Zerangue <brian.zerangue@gmail.com> How to use - Import this utility in your page, <xsl:import href="path/facebook-like-utility.xsl"/> - Call the template name="facebook-like" like so... - Required Parameter is url-to-like, all the other parameters are optional <xsl:call-template name="facebook-like"> <xsl:with-param name="url-to-like" select="'http://site.com'"/> </xsl:call-template> --> <xsl:template name="facebook-like"> <xsl:param name="url-to-like"/><!-- Required --> <xsl:param name="layout" select="'standard'"/> <xsl:param name="show_faces" select="'false'"/> <xsl:param name="font" select="'lucida grande'"/> <xsl:param name="width" select="450"/> <xsl:param name="action" select="'like'"/> <xsl:param name="colorscheme" select="'light'"/> <xsl:param name="send" select="'true'"/> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <xsl:if test="$layout='standard'"> <fb:like href="{$url-to-like}" show_faces="{$show_faces}" width="{$width}" font="{$font}" send="{$send}"> <xsl:if test="not($action='like')"> <xsl:attribute name="action"> <xsl:value-of select="$action"/> </xsl:attribute> </xsl:if> <xsl:if test="not($colorscheme='light')"> <xsl:attribute name="colorscheme"> <xsl:value-of select="$colorscheme"/> </xsl:attribute> </xsl:if> <xsl:comment> Facebook Like </xsl:comment> </fb:like> </xsl:if> <xsl:if test="$layout='button_count'"> <fb:like href="{$url-to-like}" show_faces="{$show_faces}" width="{$width}" font="{$font}" send="{$send}"> <xsl:attribute name="layout"> <xsl:value-of select="$layout"/> </xsl:attribute> <xsl:if test="not($action='like')"> <xsl:attribute name="action"> <xsl:value-of select="$action"/> </xsl:attribute> </xsl:if> <xsl:if test="not($colorscheme='light')"> <xsl:attribute name="colorscheme"> <xsl:value-of select="$colorscheme"/> </xsl:attribute> </xsl:if> <xsl:comment> Facebook Like </xsl:comment> </fb:like> </xsl:if> <xsl:if test="$layout='box_count'"> <fb:like href="{$url-to-like}" show_faces="{$show_faces}" width="{$width}" font="{$font}" send="{$send}"> <xsl:attribute name="layout"> <xsl:value-of select="$layout"/> </xsl:attribute> <xsl:if test="not($action='like')"> <xsl:attribute name="action"> <xsl:value-of select="$action"/> </xsl:attribute> </xsl:if> <xsl:if test="not($colorscheme='light')"> <xsl:attribute name="colorscheme"> <xsl:value-of select="$colorscheme"/> </xsl:attribute> </xsl:if> <xsl:comment> Facebook Like </xsl:comment> </fb:like> </xsl:if> </xsl:template> </xsl:stylesheet>