Problems with Addthis

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Problems with Addthis

Post by Mangek »

I found this thread by Don but I didn't want to bump it as it's pretty old. I tried the code Don posted with my username at addthis.com:

Code: Select all

<script type="text/javascript">
    addthis_url = '{$entry.rdf_ident|escape:url}';
    addthis_title = '{$entry.title|escape:url}';
    addthis_pub = 'mangek';
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
and it works well when viewing a single entry, but on the frontpage it grabs the link from the last entry on the page. I see Don has this up and running fine on his site, so I'm thinking I may have placed it dodgy?

Please take a look and see if you can spot what I did wrong. :)

Edit: A slight update. I checked the source, and apparently the links are being printed correctly, however when I hover the button, the url shown is for the bottom-most entry. Clicking the button takes me to the right place and prints the right url though. But it feels a little missleading. :/

Edit2: Actually, when I'm looking closer, I'm experiencing the same thing over at Don's site. Maybe it's all good, then? :?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Problems with Addthis

Post by garvinhicking »

Hi!

This code snippet always overwrites addthis_url with the title/name of the last used occurence, so this is a conceptual problem. You might want to ask the addthis! guys if there's a way so that their widget does not use the last occurence of a declared variable, but make those variables part of the URL, so that you would call:

Code: Select all

<script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12&url={$entry.rdf_ident|@escape:url}&title={$entry.title|@escape:url}&pub=mangek" ></script>
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: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Problems with Addthis

Post by Don Chambers »

Hmmm.... either I never noticed that before, or they changed something about how that script works.... I will look into it later this week if time permits....

But you are saying it WORKS correctly, its just misleading when hovered, correct?
=Don=
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Re: Problems with Addthis

Post by Mangek »

Don Chambers wrote:But you are saying it WORKS correctly, its just misleading when hovered, correct?
Correct.
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Problems with Addthis

Post by Don Chambers »

By coincidence, AddThis came up with a new version of their code just this morning.

New code can be found in my blog post here

The new version of the code is no longer misleading as to what will be bookmarked because the entry title and/or URL are not seen when the button is hovered.

I am using this new version on my primary site, and all tests proved successful so I committed a version of it to Bulletproof as well. Please let me know about any problems.

Thanks again Mangek for mentioning this since I had been meaning to update that code for quite some time! :wink:
=Don=
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Re: Problems with Addthis

Post by Mangek »

Don, I'm now using your updated script and it looks better. :)

I also like the added support for the various images, I prefer 'share' over 'bookmark'. Big kudos to you, Don! And cheers to the Addthis-team for the update on their end. :)

Let's hope they add support for easy inserting the code from their site, that would rock! :)
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Problems with Addthis

Post by Don Chambers »

Thanks - and so there is no misunderstanding, I did NOT write the actual script for the addthis button... I merely went to their site, reviewed how it worked with other CMS engines, then substituted in the s9y variables as needed. The buttons are also theirs..... I agree - I like the "share" button too and may switch my site to it as well.

Yes, it would be great if they would add s9y to their list of auto-generated scripts.. I offered to assist if they are willing to do that.
=Don=
Mangek
Regular
Posts: 85
Joined: Tue Jun 24, 2008 1:08 am
Location: Sweden
Contact:

Re: Problems with Addthis

Post by Mangek »

No I know, but it's still awesome! ;)
Post Reply