AddThisWidget
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:
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 newer version is compatible with PmWiki 2.2.58 and newer, and has no requirements for PHP version: AddThis_sharingWidget.phpΔ
- The older version is compatible with PmWiki 2.0 and higher, but requires PHP 5.4 or older: AddThis_sharingWidgetForPmWiki2258OrLower.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:
var addthis_pub="49fd93d418b90e5e";
- 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
- add your custom image to your pub directory
- declare it in config.php:
$AddThis_customBtn = $PubDirUrl."/AddThisWidget/AddThis_myCustomBtn.png";
- 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
- SocialBookmarkIcons, by Jon Haupt
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.