Social Bookmark Code - AddThis

Discussion corner for Developers of Serendipity.
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Social Bookmark Code - AddThis

Post by Don Chambers »

S9y has the findmore plugin, which is great. That plugin led me to AddThis.com. I do not want to use the findmore plugin because I do not want all the default icons.

In researching AddThis, I found a really cool drop-down version of their bookmarking plugin. You can see it live at my site here: http://www.optional-necessity.com

The findmore plugin generates unique smarty variables for the url, entry title, etc as follows:

Code: Select all

<a href="http://www.addthis.com/bookmark.php?pub=&url={$entrydata.url|escape:url}&title={$entrydata.title|escape:url}" title="Bookmark using any bookmark manager! {$entrydata.title|escape}"><img src="{$entrydata.path}button0-bm.gif" alt="Bookmark using any bookmark manager!" width="83" height="16" class="socialbkmark" /></a>
I discovered this new drop down button that will work, using these same variables in this manner:

Code: Select all

<script type="text/javascript">
  addthis_url    = '{$entrydata.url|escape:url}';   
  addthis_title  = '{$entrydata.title|escape:url}';  
  addthis_pub    = 'my_account_name';     
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
Thanks to searches on this site, review of the actual plugin, and assistance from the AddThis site, this seems to make sense:

Code: Select all

<script type="text/javascript">
    addthis_url = '{$entry.rdf_ident|escape:url}';
    addthis_title = '{$entry.title|escape:url}';
    addthis_pub = 'my_account_name';
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
Any problem with this code? Can I insert it into a template for distribution, such as bulletproof??? Pros/Cons? Thoughts?
=Don=
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

I'm using
<script type="text/javascript">
addthis_url = '{$entry.rdf_ident}';
addthis_title = '{$entry.title}';
addthis_pub = 'my_account_name';
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
which seems to work very well, not sure about the addition of the escape, is there some compelling reason for adding it, otherwise it's just extra text.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Adding the escape there is pretty useful. Else if you use the ' quote character in your entrie's title, the JS might get confused.

So the code could be put into a template, I see no problem with it (other than the requirement to make it optional ;) )

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Thanks Garvin. I was messing with this yesterday, then Carl and I BOTH were trying to get it worked out.

It's a pretty cool button, and I personally prefer it over the one offered by the findmore plugin. It is also implemented within my entries.tpl file to save grandma's performance pennies!!! :P
=Don=
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

One other thing Garvin - what are the practical differences between $entrydata.url and $entry.rdf_ident? Is it just a matter of the latter including the http portion?

Same question as it relates to the differences between $entrydata.title and $entry.title.

When Carl and I were messing around with this, we discovered that the $entrydata variables worked fine when using the findmore plugin, but did not work when that same code was coded into entries.tpl... which is what forced us to use the $entry.title link and find the rdf variable.
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

$entrydata is only available in findmore.tpl, that's why. $entrydata does not exist in entries.tpl.

Regards,
garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Thanks Garvin - I was reading some other post and was led to believe it was a global... but I just re-read that same post and realize it was about the findmore plugin.
=Don=
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

So if I modify my template with this code, I don't need the findmore plugin? That would be nice. I've got way too many plugins already.
Judebert
---
Website | Wishlist | PayPal
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

yup, you only need an account with addthis.com
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

You can move the findmore code to entries.tpl too... this just happens to be a different - and single - button. If you have a free AddThis account, and include your account number, you can track the statistics of what is being bookmarked.

EDIT: Carl and I are both using this button, so you can see it in action on either of our sites.
=Don=
DVDFan4
Regular
Posts: 8
Joined: Tue Oct 16, 2007 6:55 am

Post by DVDFan4 »

I'm having an issue with AddThis, it may be their issue and not Serendipity's, but thought I would give it a go here. I created an account at AddThis, then added the code to my entries.tpl file as shown in the earlier posts.

Code: Select all

<!-- AddThis Bookmark DropDown Button Begin -->
<script type="text/javascript">
    addthis_url = '{$entry.rdf_ident|escape:url}';
    addthis_title = '{$entry.title|escape:url}';
    addthis_pub = 'my_account_name'; 
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12"></script><p></p>
<!-- AddThis Bookmark DropDown Button END -->
The button works fine in some cases, but not in others. For example, the Digg and Facebook icons seem to work on a post, but the reddit, del.icio.us and other icons simply open another web window with my homepage. It's also inconsistent on entries, with the first entry being the most problematic.

Any ideas?

My site is http://www.suggestedthinking.com/

Thanks,
Paul
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Could you tell us an actual entry and service where this behaviour occurs? All entries where I tried to use "reddit" worked for me.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
DVDFan4
Regular
Posts: 8
Joined: Tue Oct 16, 2007 6:55 am

Post by DVDFan4 »

If I hover over the icon to get the dropdown, then select reddit from within the dropdown, I get a new browser window with my main page. It happens on at least the first 2 posts on the main page, that's all I tested this morning. I am using IE7.
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

I just tried it on your first 5 posts..... I am having no problems with FF2. Could it be cache related? Some kind of IE7 pop-up blocker?
=Don=
DVDFan4
Regular
Posts: 8
Joined: Tue Oct 16, 2007 6:55 am

Post by DVDFan4 »

You were right, it seemed to be somehow related to the pop-up blocker or cache. I allowed pop-ups on the page and cleared the cache and it seems to be working now.

Thanks for the help.
Post Reply