Author:
bzerangue
Version:
1.0
Release Date:
31 Aug 2011
Category:
Third-Party Integration

Description

Easily add a Twitter button to your website.

To do so...

<xsl:call-template name="twitter-button">
         <xsl:with-param name="data-url" select="'put-url-that-you-want-to-tweet-about-here'"/>
         <xsl:with-param name="data-count" select="'horizontal'"/>
</xsl:call-template>

XSLT

View Raw
<?xml version="1.0" encoding="UTF-8" ?>
<!--
	Twitter Button: XSL Utility
	Created by Brian Zerangue on 2011-08-31.
-->

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template name="twitter-button">
		<xsl:param name="data-url" /> <!-- required -->
		<xsl:param name="data-via" /> <!-- optional // use your screenname -->
		<xsl:param name="data-text" /> <!-- optional -->
		<xsl:param name="data-related" /> <!-- optional -->
		<xsl:param name="data-count" select="'none'"/> <!-- options // horizontal, vertical, none -->
		
		<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
		<div>
			<a href="http://twitter.com/share" class="twitter-share-button">
				<xsl:attribute name="data-url">
					<xsl:value-of select="$data-url" />
				</xsl:attribute>
				<xsl:if test="$data-via!=''"> 
					<xsl:attribute name="data-via">
						<xsl:value-of select="$data-via" />
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="$data-text!=''">
					<xsl:attribute name="data-text">
						<xsl:value-of select="$data-text" />
					</xsl:attribute>
				</xsl:if>
				<xsl:if test="$data-related!=''">
					<xsl:attribute name="data-related">
						<xsl:value-of select="$data-related" />
					</xsl:attribute>
				</xsl:if>
				<xsl:attribute name="data-count">
					<xsl:value-of select="$data-count" />
				</xsl:attribute>
				<xsl:text>Tweet</xsl:text>
			</a>
		</div>
	</xsl:template>
</xsl:stylesheet>

Discuss this XSLT Utility

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details