Asked and Answered: A Digg Widget for Blogs

** Thanks for the Bugg Fixes Everyone! WordPress Mangled the Code, But Everything Works Now! Just Copy-and-Paste **

A recent story on Digg requested that a digg widget be created for bloggers to add to their sites. Digg already provides a javascript list of stories dugg, but it does not offer things such as how many diggs it has received, nor does it offer links to the actual stories themselves (just to the page on digg). So, without further adieu, a Digg Widget for everyone else.

<script>
  // YOUR USERNAME
  var username        = "your user name";

  // NUMBER OF STORIES TO SHOW, MAX 11
  var stories_to_show = 5;

  // DATA TYPE: dugg, submitted, or commented
  var data_type       = "dugg";

  document.write('<scri','pt src="http://www.thegooglecache.com/digg-widget.php?vals='+username+'**'+stories_to_show+'**'+data_type+'"></scr','ipt>');
</script>


<noscript>
  <a href='http://www.thegooglecache.com'>Digg Widget by Virante</a>
</noscript>

Just paste the code onto your page and change the username to whatever your username is. You can change the number of stories to show (up to 10), or whether it displays stories that were dugg, submitted, or commented on.

The output should look something like this…

No tags for this post.

3 Comments

  1. Sebastian
    Feb 14, 2007

    nice backlink in the code 😉

  2. Benjamin Niemann
    Feb 15, 2007

    You’re missing the tag and it should be
    …’…, not …’… to make the code valid.
    Also the quotes are not really suited for copy-n-paste (probably mangled by your blog software) and the example does not work (because of the relative URL to digg-widget.php).

  3. Benjamin Niemann
    Feb 15, 2007

    Grml… HTML need to be escaped…

    The </script> is missing.
    It should be ..</’,’script>.. instead of </scr’,’ipt>

    Hope it works now..

Submit a Comment

Your email address will not be published. Required fields are marked *