Twitter Feeds in Umbraco using XSLT
Posted
by
Vizioz Limited
on Vizioz Umbraco Blog
See other posts from Vizioz Umbraco Blog
or by Vizioz Limited
Published on 2009-11-15T07:41:00.000-08:00
Indexed on
2010/12/06
17:00 UTC
Read the original article
Hit count: 847
It may also be useful for those of you using Darren Ferguson's "Feed Cache" package as the demo on Darren's site does not add links to the tweets.
To use this XSLT you simple call the XSLT Template passing in your Twitter message:
<xsl:call-template name="formaturl">
<xsl:with-param name="url" select="text"/>
</xsl:call-template>
Then add the XSLT template to your XSLT macro (outside of the main template)
<xsl:template name="formaturl">
<xsl:param name="twitterfeed"/>
<xsl:variable name="transform-http" select="Exslt.ExsltRegularExpressions:replace($twitterfeed, '(http\:\/\/\S+)',ig,'<a href="$1">$1</a>')"/>
<xsl:variable name="transform-https" select="Exslt.ExsltRegularExpressions:replace($transform-http, '(HTTps\:\/\/\S+)',ig,'<a href="$1">$1</a>')"/>
<xsl:variable name="transform-AT" select="Exslt.ExsltRegularExpressions:replace($transform-https, '(^|\s)@(\w+)',ig,' <a href="http://www.twitter.com/$2">@$2</a>')"/>
<xsl:variable name="transform-HASH" select="Exslt.ExsltRegularExpressions:replace($transform-AT, '(^|\s)#(\w+)',ig,' <a href="http://www.twitter.com/search?q=$2">#$2</a>')"/>
<xsl:value-of select="$transform-HASH" disable-output-escaping="yes"/>
</xsl:template>
You should find that this now replaces all the @names, #names and URL's with links!
© Vizioz Umbraco Blog or respective owner