Saturday, June 09, 2007

Blogger Template: Digg This button with a custom URL

As expected in migrating over to blogger all my posts have now got slightly different URLs. The question is what to do with posts which have already been dugg with the old URL?

The first step was to set up forwards from my old URLs with Apache 2.2's mod_rewrite.

Then using the instructions posted on ajaxcold, I integrated the "digg this!" button with automatically generated URLs. In the case of old stories I want to be able to specify a URL.
  1. In your Blogger Template (First tick "Expand Widgets"):
    • Below this line (Or anywhere between <head> and </head>):
    • Add these lines:
      <!-- Digg Url Override // -->
      <script type="'text/javascript'">
      var digg_url_override = null;

  2. In the existing "digg this!" button code from ajaxcold's tutorial:
    • Replace the line:
      digg_url = '';
    • With these lines:
      if (digg_url_override === null ) {
      digg_url = '';
      } else {
      digg_url = digg_url_override;
      digg_url_override = null;

Then when (re-)posting a story which needs a custom URL, switch to HTML editor, and at the very start on a single line paste:

<script type="'text/javascript'"> digg_url_override = 'CUSTOM_URL';</script>

Where CUSTOM_URL is the custom URL you want people to keep digging.



Daniel said...

David, can you tell me how can I automatically add on Blogger platform a Digg link on every post?

D. Patrick Caldwell said...

Awesome! Thanks a lot. I used your script (with a few modifications) and added several scripts of my own. If you'd like, you can find them on my blog.