Archive for the ‘Developers’ Category

How do I get the ShareThis Bar?

With this implementation, publishers are now able to present a select number of social web services “outside” of the button and directly on the page, while still leveraging the ShareThis tracking technology and maintaining the ShareThis experience. For example, a publisher can include Email, Facebook and Twitter buttons on the page next to the ShareThis button.

In order to begin, please follow the steps below:

Step 1

To begin, you will need to include ShareThis JS code in the header of your page. Below is an example of the code.
<script type=”text/javascript” src=”http://w.sharethis.com/button/sharethis.js#publisher=00000000-0000-0000-0000-000000000000&type=website&button=false”></script>

Step 2

In order to display and track the social web services outside of the ShareThis button, you will need to define the HTML elements on the page. The services which can be “pulled out” of the ShareThis widget are Email, Facebook, Digg, Twitter and Yahoo! Buzz. Below is an example of what your code should look like for each service.
<a id=”ck_email” class=”chicklet” href=”javascript:void(0);”><img src=”http://farm1.static.flickr.com/92/211633454_5a625e2d1d.jpg” />Email</a>
<a id=”ck_facebook” class=”chicklet” href=”javascript:void(0);”><img src=”http://www.facebook.com/favicon.ico” />Facebook</a>
<a id=”ck_digg” class=”chicklet” href=”javascript:void(0);”><img src=”http://digg.com/favicon.ico” />Digg</a>
<a id=”ck_twitter” class=”chicklet” href=”javascript:void(0);”><img src=”http://twitter.com/favicon.ico” />Twitter</a>
<a id=”ck_ybuzz” class=”chicklet” href=”javascript:void(0);”><img src=”http://buzz.yahoo.com/favicon.ico” />Buzz Up!</a>
<a id=”ck_sharethis” class=”chicklet” href=”javascript:void(0);”><img src=”http://sharethis.com/favicon.ico” />ShareThis</a>

The above example is using standard images for each service; you are able to define the image by changing the source location.

Step 3

Finally, you will need to define the shared object via SHARETHIS.addEntry() call and attach the appropriate button and social web service chicklets. Below is the code that needs to go in the <body> of your page.
<script type=”text/javascript”>
var shared_object = SHARETHIS.addEntry({
title: “My Article”,
url: “http://domain.com/article.html”
});

shared_object.attachButton(document.getElementById(”ck_sharethis”));
shared_object.attachChicklet(”email”, document.getElementById(”ck_email”));
shared_object.attachChicklet(”facebook”, document.getElementById(”ck_facebook”));
shared_object.attachChicklet(”digg”, document.getElementById(”ck_digg”));
shared_object.attachChicklet(”twitter”, document.getElementById(”ck_twitter”));
shared_object.attachChicklet(”yahoo_buzz”, document.getElementById(”ck_ybuzz”));
</script>

Sample HTML

<html>
<head>
<title>ShareThis Chicklet Test</title>
<script type=”text/javascript” src=”http://w.sharethis.com/button/sharethis.js#publisher=00000000-0000-0000-0000-000000000000&type=website&button=false”></script>
<style type=”text/css”>
* {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}

a.chicklet img {
border: 0;
height: 16px;
width: 16px;
margin-right: 3px;
vertical-align: middle;
}

a.chicklet {
height: 16px;
line-height: 16px;
margin-right: 6px;
}
</style>
</head>

<body>
<a id=”ck_email” class=”chicklet” href=”javascript:void(0);”><img src=”http://farm1.static.flickr.com/92/211633454_5a625e2d1d.jpg” />Email</a>
<a id=”ck_facebook” class=”chicklet” href=”javascript:void(0);”><img src=”http://www.facebook.com/favicon.ico” />Facebook</a>
<a id=”ck_digg” class=”chicklet” href=”javascript:void(0);”><img src=”http://digg.com/favicon.ico” />Digg</a>
<a id=”ck_twitter” class=”chicklet” href=”javascript:void(0);”><img src=”http://twitter.com/favicon.ico” />Twitter</a>
<a id=”ck_ybuzz” class=”chicklet” href=”javascript:void(0);”><img src=”http://buzz.yahoo.com/favicon.ico” />Buzz Up!</a>
<a id=”ck_sharethis” class=”chicklet” href=”javascript:void(0);”><img src=”http://sharethis.com/favicon.ico” />ShareThis</a>

<script type=”text/javascript”>
var shared_object = SHARETHIS.addEntry({
title: document.title,
url: document.location.href
});

shared_object.attachButton(document.getElementById(”ck_sharethis”));
shared_object.attachChicklet(”email”, document.getElementById(”ck_email”));
shared_object.attachChicklet(”facebook”, document.getElementById(”ck_facebook”));
shared_object.attachChicklet(”digg”, document.getElementById(”ck_digg”));
shared_object.attachChicklet(”twitter”, document.getElementById(”ck_twitter”));
shared_object.attachChicklet(”yahoo_buzz”, document.getElementById(”ck_ybuzz”));
</script>
</body>
</html>

This is a basic overview of how the ShareThis bar works, you’ll need to customize the code to fit your needs and the design of your website or blog.

Popularity: 4%

How do I make the widget appear in a new popup window?

This is achieved by setting the “popup” JavaScript element to true (default is false):

<script language=”javascript” type=”text/javascript”>
SHARETHIS.addEntry({
title:’My Share Object!’,
summary:’Sharing is good for the soul.’
},{popup:true});
</script>

*Note: There is a global solution at http://support.sharethis.com/publishers/publishers-faq/configuration/69

Popularity: 18%

How do I create my own custom ShareThis button?

In order to create your own custom ShareThis button you must first turn off our output of the button by setting the “button” API option to “false”. Then you can create your own button out of HTML and then bind our SHARETHIS.addEntry code to it.

You may modify the ShareThis button icon to use different colors or sizes but the shape and look should be maintained. You can get the ShareThis icon image files here.

Below is an example of this ShareThis API procedure:


<script language="javascript" type="text/javascript">
//Create your sharelet with desired properties and set button element to false
var object = SHARETHIS.addEntry({
title:'share',
summary: 'Sharing is good for the soul.'},
{button:false});
//Output your customized button
document.write('<span id="share"><a href="javascript:void(0);"><img src="/my_share_icon.gif" />Share!</a></span>');
//Tie customized button to ShareThis button functionality.
var element = document.getElementById("share");
object.attachButton(element);
</script>

Popularity: 42%

How do I execute my own function along with the ShareThis button?

To tie a custom function to the ShareThis button, you must set the JavaScript element “onclick” to the name of your custom function:

Below is an example of this ShareThis API procedure:

<script language=”javascript” type=”text/javascript”>
//Use a customized callback routine. For example:
function custom(sharelet){
alert(sharelet.properties.title);
//Return true to continue share event
return true;};
//Create a sharelet with button element set to false and the custom handler
var object = SHARETHIS.addEntry({
title:’share’,
summary: ‘Sharing is good for the soul’},
{button:false, onclick:custom};
//Create customized button and attach it to the share object
document.write(‘<span id=”share”><ahref=”javascript:void(0);”>Share!</a></span>’);
var element = document.getElementById(“share”);
object.attachButton(element);
</script>

Popularity: 19%

How do I allow embedded elements to be visible while the iFrame is loaded?

In order to allow embedded elements to be visible, the “embeds” JavaScript element must be set to true.

This JavaScript element (embeds) defaults to false due to possible display problems where flash will sometimes display through the widget iFrame. If you set “embeds” to true but encounter problems with Flash, another alternative is to use the the “popup” JavaScript element where the ShareThis widget will instead display in a new popup window.

Below is an example of the ShareThis API procedure which includes the “embeds” JavaScript element:

<script language=”javascript” type=”text/javascript”>< br/>
SHARETHIS.addEntry({
title:’My Share Object!’,
summary:’Sharing is good for the soul.’},
{embeds:true});
</script>

Below is an example of the ShareThis API procedure which includes the “popup” JavaScript element:

<script language=”javascript” type=”text/javascript”>
SHARETHIS.addEntry({
title:’My Share Object!’,
summary:’Sharing is good for the soul.’},
{popup:true});
</script>

*Note: There is a global solution at http://support.sharethis.com/publishers/publishers-faq/configuration/70

Popularity: 18%

What do I do if I’m having problems with Flash showing through the ShareThis widget?

If Flash is showing through the ShareThis widget iFrame, you can either:

1) Disable the Flash while the ShareThis widget is in use by setting the “embeds” JavaScript element to false (default is false).Or…

2)Use the the “popup” JavaScript element where the ShareThis widget will instead display in a new popup window.

Below is an example of the ShareThis API procedure which includes the “embeds” JavaScript element:

<script language=”javascript” type=”text/javascript”>
SHARETHIS.addEntry({
title:’My Share Object!’,
summary:’Sharing is good for the soul.’},
{embeds:false});
</script>

Below is an example of the ShareThis API procedure which includes the “popup” JavaScript element:

<script language=”javascript” type=”text/javascript”>
SHARETHIS.addEntry({
title:’My Share Object!’,
summary:’Sharing is good for the soul.’},
{popup:true});
</script>

Popularity: 18%

How do I change the positioning of the ShareThis widget in relation to the ShareThis button link?

The ShareThis widget is defaulted to appear at the bottom-right of the ShareThis button link. This positioning can be changed by assigning integer values to the “offsetLeft” and “offsetTop” JavaScript Elements. The integer values assigned to these JavaScript Elements are relative to the default location of the top-left corner of the ShareThis widget. For example, for the widget to appear at the bottom-left of the ShareThis button link, assign the following values:

<script language=”javascript” type=”text/javascript”>
//Create your sharelet with desired properties
SHARETHIS.addEntry({
title:’share’,
summary: ‘Sharing is good for the soul.’},
//Assign integer values specifying the desired positioning of the ShareThis widget
{offsetLeft: -349, offsetTop: 10});
</script>

*The width of the ShareThis button link is dependent on the font styling of the label so this example may not work for your site.

Popularity: 19%