Skip to content

Instantly share code, notes, and snippets.

@bzerangue
Last active January 10, 2020 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bzerangue/838226 to your computer and use it in GitHub Desktop.
Save bzerangue/838226 to your computer and use it in GitHub Desktop.
[XSLT] Facebook Like XSLT Utility
<?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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment