Creative Web Specialist - An online portfolio and resource site of Warren Buckley

Latest Posts

Apr21th

Twitter Umbraco Package version 1.2

Hello all,
After talking to Nisse Bryngfors, he requested that the URLs in tweets would automatically be made as urls and marked up with anchor tags. In addition to this he requested that @username replies were also automatically generated into anachor tags.

For example:

check out this site http://google.co.uk Nice design @warrenbuckley

would now become

check out this site
http://google.co.uk
Nice design
@warrenbuckley

This has been made possible with a new function in the XSLT Extension CWS.Twitter called FormatURLS.
So to format your tweet use this syntax in your XSLT.



I have reposted the instructions below for people who didn't use my previous version.

This package installs the following files:

  • bin/CWSHelperTwitter.dll
  • xslt/CWS_twitterStatus.xslt
  • /usercontrols/Installer/CWSTwitter/cwsTwitterInstaller.ascx

The installer usercontrol cwsTwitterInstaller.ascx is used to modify the /config/xsltExtensions.config
to setup my custom XSLT extension to allow us to modify the strange format of the twitter date format.

The actual package installs the following into umbraco:

  • Macro: [XSLT] CWS:Display Twitter Status
  • XSLT: CWS_twitterStatus.xslt

To use this package just install this package, to do this take the following steps.

  1. Login to umbraco
  2. Goto the Developer section
  3. Right click the Macros node
  4. Select Import Package
  5. Press Browse and find the zip package file you have downloaded
  6. Follow the steps in the wizard
  7. Once installed insert the macro into your XHTML template
  8. Insert your twitter id (not username), the number of items you want to display (upto 20) and check the box if you wish to include your friends tweets.

How do I find my Twitter user id?

You can find your twitter id by browsing to your twitter page, for example http://twitter.com/warrenbuckley and clicking on the RSS link at the bottom of the page. Which loads your RSS feed like this, http://twitter.com/statuses/user_timeline/9751992.rss
So in my case my Twitter user id is 9751992

Customisation

To customise the XHTML for the tweets display take a look at the XSLT file installed. This should be easy to read and edit, it is possible to modify your XSLT to include more things from the XML that twitter returns to us. How about the users real name, the users site it's really upto you?

Check out the example XML files
http://twitter.com/statuses/user_timeline/9751992.xml
http://twitter.com/statuses/friends_timeline/9751992.xml

Download

So without further-a-do here is the package for you to download.
Download Creative Website Specialist - Twitter Package v1.2.0

4 comments
21st May, 2008
Hi Warren,
Does this make a request to Twitter each time you visit a page containing the Macro - (presuming Macro caching is turned off).

I presume that you are just consuming the appropriate RSS feed and transforming it?

My concern is that Twitter has been a little flaky in terms of uptime. Would my page take ages if Twitter is down while waiting for the request to Twitter to timeout?
07th June, 2008
Warren,

Installed twitter package today, which is great, but found a tiny misbehaviour when multiple twitter accounts are in the tweet

Eg. @umbraco @netaddicts -> the FormatURLS doesn't replace the second twitter account match.

Haven't found a patch myself yet. I'll see if I can come up with a solution.

Greetz,
/Dirk

08th June, 2008
Hi Warren,

Found a solution that at least solves my *problem*. I might do some extra testing to verify whether that solutions covers it all.

Replace second Regex.Replace() input param by

@"(\@)(\w*)"

Greetz,
/Dirk
08th June, 2008
Oops,

Forgot to mention the second param also needs a slightly different syntax:

(Sending a mail through Linkedin 'cause solution string gets blocked by asp.net

...(here comes the solution)...

/Dirk
Post a comment »

My Skill Set

This is a quick list of my skill set to date

  • XHTML
  • CSS
  • Photoshop (Slicing)
  • XSLT
  • ASP.NET
  • Umbraco .NET CMS

My Last.FM

I am listening to:

  • I'm Not Gonna Teach Your Boyfriend How To Dance With You (The Twelves Remix) by Black Kids1 Dec 2008, 17:34
  • Gorecki by LambLamb1 Dec 2008, 17:28
  • Use Somebody by Kings of Leon1 Dec 2008, 17:24

My Flickr

Check out all my pics from flickr

Warren Buckley is an umbraco MVP 2008/2009 Warren Buckley is an umbraco level 1 certified developer

Photo of Warren Buckley Warren Buckley is a Creative Web Specialist based in Leigh on Sea, Essex , UK.