ShareThis button in MovableType 4

| No Comments | No TrackBacks
share-icon-128x128_normal.pngShareThis is a nice addition to any web page. Instead of adding links for Digg, Delicious, Reddit, Myspace, Facebook, etc etc to your page and and coding a "send this article to a friend" function yourself, you can add the ShareThis button, which does all of the above (and more). When a user clicks on the button, a window is opened that lets you choose how you want to share this page: Via social web, blog post or sending email/IM/SMS.


To add this button, you just have to insert some Javascript code into your web page. The URL is detected by the script and sent to the ShareThis server. This is fine as long as you want to share this exact page. But it's not ok if you want to share a specific part of a page, for example on a blog. Your blog always has the same URL, but the posts are changing constantly. Fortunately, every post has a unique URL, by which it can be reached directly. And ShareThis has a pretty flexible API that lets you set the URL you want to share.

Here's how to add the ShareThis button to a MovableType 4 blog:

  1. Register at ShareThis, get the base code from their customization tool. It looks something like this:
    <script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#tabs=web%2Cpost%2Cemail&amp;charset=utf-8&amp;style=default&amp;publisher=838f887-a9a7d-4c23-fafe-889e53268337"></script>
    This code provides the base functionality for the ShareThis button.

  2. Paste that (your) code into the header template between <head> and </head>, so it will be included on every page. Save.

  3. Go to the template(s) of the page where you want the ShareThis button. This would normally be the entry-related templates. Paste the following code into the place where you want the button to appear, e.g. within the asset-footer div tags to have the button below an entry.
    <script language="javascript" type="text/javascript">
SHARETHIS.addEntry({title:'<$mt:EntryTitle$>',summary:'<$mt:EntryExcerpt$>',url: '<$mt:EntryLink$>'}, {button:true} );
</script>

  4. Rebuild your blog and the ShareThis buttons will appear.

No TrackBacks

TrackBack URL: http://www.blogplanet.net/cgi-bin/copprhead/mt-tb.cgi/6

Leave a comment