Can you digg it?
Everyone else seemed to have these “digg it” links on their sites, so I figured I needed it too since that’s the web 2.0 way apparently. So, now I have some pretty little “digg it” links beside each post! I haven’t tried any yet, but they should work. I’ll just wait for my first digg to happen and hope someone used a link to do it
Update: I have updated the iframe tag code to encode the URL, and also added a fix for IE so that the iframe would display properly.
If people are interested in adding the links to their own installations you can follow the instructions on digg.com’s site about integration which says to just insert a <script> tag, but I personally don’t really like the idea of using in-line <script> tags. They belong in the header, not strewn about in the body. So instead of using their code, I decyphered what their code did and just inserted the actual HTML. It turns out that all their script really does is just produce an <iframe> tag, so I took what they produced and tweaked it a bit and made it all web 2.0.
<style type="text/css">
.digger {
width: 52px;
height: 80px;
overflow: hidden;
border: none;
}
</style>
<iframe class="digger" src="http://digg.com/tools/diggthis.php?u=<?php the_permalink(); ?>"></iframe>
<iframe class="digger" frameborder="0" scrolling="no" src="http://digg.com/tools/diggthis.php?u=<?php echo rawurlencode(get_permalink()); ?>&t=<?php echo rawurlencode(the_title()); ?>&b=<?php echo rawurlencode(the_excerpt()); ?>"></iframe>
That’s essentially all you need – place the CSS anywhere really (I just made mine inline for now for simplicity), and then put the <iframe> tag in to the “post loop” in the index.php page for your theme and you’re all done! You’ll want to add some extra CSS to the class though so you can position/format it nicely, but you’ll want to keep what I’ve given you already.
Enjoy! No fancy plugins required (though perhaps one would be nice – maybe I’ll add one when I dive in to WordPress plugins some time) and no fancy JavaScript required either!
IE doesn’t like your iframe. It puts horiztonal and vertical scrolls on it which hide half the box.
@Mike: Thanks, I hadn’t even bothered to check the site in IE since I wasn’t too bothered with it, but I had just figured stuff was working in it. It turns out that IE apparently was rendering a border for the iframe tag even though I have CSS to disable them.
It’s some IE bug that it requires the src document to disable borders explicitly (on the body element) otherwise you get a border in your iframe despite what any CSS on your site has to say about it.
Fixed it by adding frameborder=”0″ and scrolling=”no” to the tag itself, though I am now in violation of XHTML 1.1 which is what I’d like to be using eventually.
Hey thanks for the tip, but it looks like Digg is blocking this trick now. Too bad, their slow js widget is killing my IE6 visitors
@Advice: I just checked the links after getting your comment and they seemed to be ok. Just to be sure though I took another look at their integration code and it appears they are now escaping the HTML in their JavaScript (I don’t believe they were before).
So, in response to their update, I have updated my code, and it appears to work fine (you can always digg an article here to find out).