Launched in 2006, addthis has become the #1 bookmarking and sharing button on the Internet. Many serendipity developers and website owners have incorporated the addthis code, or "widget", into their serendipity templates. I personally added it to a number of my own templates, and this code has been a part of the current serendipity default template Bulletproof since its initial release. Addthis has maintained compatibility with older versions of their scripts, but I decided it was time to update the script, especially since they just released a new version today.
Wednesday, May 27. 2009
New AddThis button code for Serendipity Templates
Launched in 2006, addthis has become the #1 bookmarking and sharing button on the Internet. Many serendipity developers and website owners have incorporated the addthis code, or "widget", into their serendipity templates. I personally added it to a number of my own templates, and this code has been a part of the current serendipity default template Bulletproof since its initial release. Addthis has maintained compatibility with older versions of their scripts, but I decided it was time to update the script, especially since they just released a new version today.
The original code I used in bulletproof and other templates is located in the smarty template file named entries.tpl and is as follows:
There are several button choices. Below are the current button choices, and the corresponding <img> code necessary to fetch each button:
(used in example above)
For more information, please visit the Addthis website, forum, or blog.
If you enjoyed this article, please leave a comment and bookmark it at your favorite social bookmarking sites using the Bookmark button below so that others will enjoy it as well!
<div class="addthiswidget">
<script type="text/javascript">
addthis_url = '{$entry.rdf_ident|escape:url}';
addthis_title = '{$entry.title|escape:url}';
addthis_pub = '{$template_option.addthisaccount}';
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
</div>
Addthis has changed the javascript a bit since then, but the basic concept remains unchanged. I have, however, come to the conclusion that the URL does not need to be escaped as s9y is already converting potentially bad characters. The entry title should still be escaped to avoid problems with the addthis javascript. So, the new version of the code is this:
<div class="addthiswidget">
<a href="http://www.addthis.com/bookmark.php?v=250" onmouseover="return addthis_open(this, '', encodeURIComponent('{$entry.rdf_ident}'), encodeURIComponent('{$entry.title|escape:url}'));" onmouseout="addthis_close()" onclick="return addthis_sendto()" title="Bookmark and Share" target="_blank"><img src="http://s7.addthis.com/static/btn/lg-bookmark-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0" /></a>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub={$template_option.addthisaccount}"></script>
</div>
If you are not using bulletproof, remember to replace {$template_option.addthisaccount} with your addthis account name/number if you have one, otherwise that should simply be deleted. Also note that that account name/number is not enclosed within quotes as the entire script source is already enclosed within double quotes in this version.There are several button choices. Below are the current button choices, and the corresponding <img> code necessary to fetch each button:
(used in example above)
<img src="http://s7.addthis.com/static/btn/lg-bookmark-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0" /><img src="http://s7.addthis.com/static/btn/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0" /><img src="http://s7.addthis.com/static/btn/lg-addthis-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0" /><img src="http://s7.addthis.com/static/btn/sm-bookmark-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0" /><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0" />
Serendipity's Bulletproof template has been updated in SVN with this modification, or you can update your own copy of entries.tpl if you do not want to fetch the latest nightly build. For more information, please visit the Addthis website, forum, or blog.
If you enjoyed this article, please leave a comment and bookmark it at your favorite social bookmarking sites using the Bookmark button below so that others will enjoy it as well!
Trackbacks
AddThis für Serendipity
Ich muss zugeben, ich habe mich bisweilen mit dem Dienst AddThis nicht sehr beschäftigt. Ich kann dieses Service in mein eigenes Blogs, in meine eigene Website integrieren. Danach stehen meinen LeserInnen ein Bookmarking Tool für rund 50 Social Networks
Ich muss zugeben, ich habe mich bisweilen mit dem Dienst AddThis nicht sehr beschäftigt. Ich kann dieses Service in mein eigenes Blogs, in meine eigene Website integrieren. Danach stehen meinen LeserInnen ein Bookmarking Tool für rund 50 Social Networks


Justin Thorp
Homepage
05/28/2009 09:40AM
Don Chambers
Homepage
05/28/2009 11:05AM
Let me know what you would need to include an option to generate the code for Serendipity, much like you currently have options for WP, TypePad, etc.
Jessica H
06/23/2009 01:24PM
I tried this code in the entries.tpl I'm not using the Bulletproof template.
Whenever I try sharing a blog post on say twitter the url comes up like this 'http://%7B%24entry.rdf_ident%7D/'
What am I doing wrong?
Thanks
Don Chambers
Homepage
06/23/2009 01:49PM
It might also be helpful if you provided your URL. Also provide your email address in the comment form - only I can see it.
Jessica H
06/24/2009 08:11AM
I added my email & website. Warning the site is an adult blog, however I really need this to work......
Many thanks
Don Chambers
Homepage
06/24/2009 10:58AM
I think you have entered the code twice - once from an example you may have seen on the addthis site, and a second time from my example above. Use only the code from my example in this entry.
Also make sure that you replace the addthis account number code if you are not using bulletproof.
Jessica H
06/24/2009 11:29AM
Your code has only been added once to the entries.tpl The other addthis code you might be seeing is the bookmark in the sidebar.
Replacing the addthis account number does not make a difference to the url it's picking up like this '%7B%24entry.rdf_ident%7D'.
That email address should be working though.
Thank you.
Jersey Display Case
Homepage
07/04/2009 12:51AM
paul
Homepage
09/13/2009 10:59AM
You should post this on the serendipity forums if you haven't already.
Also, has AddThis responded to your request to add Serendipity to their list of blog options for their code generator?
Patrick
Homepage
09/14/2009 07:08PM
Eric Hill
Homepage
10/24/2009 03:32AM
Kristoff
Homepage
11/12/2009 09:22AM
Mario
Homepage
01/16/2010 03:46AM