[TYPO3] Building a "Digg this" link

Jason A. Lefkowitz jason at jasonlefkowitz.net
Wed Jan 10 20:56:25 CET 2007


Hey everybody...

I've been playing around with adding "Digg this" links to my TYPO3 site. 
  If you don't know about Digg (http://www.digg.com/), it's a "Web 2.0" 
news site where the content is submitted and voted on by the readers. 
You can add links to the pages on your site that will let Digg users 
submit those pages for publication on Digg.

The format of the URL for a "Digg this" link is like this:

http://digg.com/submit?phase=2&url=www.UniqueURL.com&title=StoryTitle&bodytext=StoryDescription&topic=YourSelectedTopic

... where "url" is the url to the page you want the user to submit, 
"title" is the title of the page/story, "bodytext" is the text of the 
submission (this is optional), and "topic" is a category of stories from 
Digg's taxonomy.  (more info available at http://digg.com/tools/integrate).

I was thinking it would be relatively easy to use Typoscript to build 
links on every page to allow users to Digg that page.  Assuming we've 
set up a Typoscript object in the data structure called lib.digg_this to 
hold the link, and we want to submit our pages into Digg's "Apple" 
topic, my thought was this should work:

lib.digg_this = TEXT
lib.digg_this.value = Digg this page
lib.digg_this.dataWrap = <a 
href="http://digg.com/submit?phase=2&url=www.mysite.com/index.php?id={ 
page : uid }&title={ page : title }&topic=apple"> | </a>

And in most cases, it does.  However, the value of the "title" attribute 
(being inserted via the { page : title } gettext function) isn't 
URL-encoded, so if the title of the page contains any special 
characters, you get weird results.

So I've been trying to figure out how to URL-encode the link HREF, 
substitute the encoded value into the datawrap, and then wrap it all 
around the TEXT object.  But after hours of thinking, I can't come up 
with a solution.

I'm sure there's some obvious and easy way that I'm just missing.  Any 
ideas?

Thanks!

-- Jason Lefkowitz


More information about the TYPO3-english mailing list