AddThisWidget

Summary: Embed the 'AddThis' widget to enable easy sharing of webpages on facebook, delicious, twitter, and other social networking sites.
Version: 2009-08-11b
Prerequisites:
Status:
Maintainer: overtones99
License: GPL2
Discussion: AddThisWidget-Talk

Questions answered by this recipe

How do I add the 'Add This' social bookmarking widget to my webpage?

Description

Embed the 'AddThis' widget from http://addthis.com to enable easy sharing of webpages on facebook, delicious, twitter, and other social networking sites.

Notes

Code:

To Install:

add somewhere in your config.php:
include_once("$FarmD/cookbook/AddThis_sharingWidget.php");

Then put one of these two versions in your cookbook directory as a file named AddThis_sharingWidget.php:

the 'AddThis' widget Custom Markup looks like:

(:addThis username="myUsername" btn="sm-share":)

Where to Embed it:

According to the AddThis.com instructions, the embedded script should be added somewhere in the <BODY> of your page, so feel free to add it anywhere you would normally place your markup...

Current Arguments:

username -- created on addthis.com site - if you sign up for a username on addthis.com, you can access addthis.com's sharing statistics. even anonymous users seem to have usernames assigned in the form of a long string of random-ish characters (i.e. "49fd93d418b90e5e")... it may or may not work without it (i haven't checked), so to get the anonymous username just hit the "get your button code" button on the addthis.com site, and look for the part of the script that says something like:
var addthis_pub="49fd93d418b90e5e";
use the number generated for you in quotes for your username if you don't have a username...
btn - button styles -
  • the standard ones currently enabled are "plus", "sm-share", "lg-share", "sm-bookmark", "lg-bookmark", and "lg-addthis"; the default is "sm-share"
  • you can also create your own custom image and use it instead - just
    1. add your custom image to your pub directory
    2. declare it in config.php:
      $AddThis_customBtn = $PubDirUrl."/AddThisWidget/AddThis_myCustomBtn.png";
    3. call it in the Markup:
      (:addThis username="myusername" btn="custom":)
    - there are currently two versions: "custom" & "custom_NoText" - custom adds $AddThis_defaultText after it as a text link
  • and finally, you can just use text, which is set by $AddThis_defaultText

More info on the 'Add This' widget: http://addthis.com

Examples

Standard Buttons

(:addThis username="myUsername" btn="plus":)

(:addThis username="myUsername" btn="sm-share":)

(:addThis username="myUsername" btn="lg-share":)

(:addThis username="myUsername" btn="sm-bookmark":)

(:addThis username="myUsername" btn="lg-bookmark":)

(:addThis username="myUsername" btn="lg-addthis":)

Plain Text

text can be assigned via $AddThis_defaultText in config.php
(:addThis username="myUsername" btn="text":)

Custom Buttons

reminder: you'll need assign your custom via $AddThis_customBtn = $PubDirUrl."/AddThisWidget/AddThis_purplePlus.png";

(:addThis username="myUsername" btn="custom":)

(:addThis username="myUsername" btn="custom_NoText":)

Release Notes

2015-08-11b - modified to work under PHP 5.5+ -- RandyB
2015-08-11 - added GPL v2 licensing info
2009-05-03b - added more standard buttons, incorporated ability to add custom button, overtones99
2009-05-03 - initial release, overtones99

See Also

Contributors

  • overtones99 (feel free to edit this recipe. i'm not always available to maintain this sort of thing, so feel free to dive in and amend this...)

Comments

See discussion at AddThisWidget-Talk

User notes +3 -1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.