Add a single script tag per page

benpjohnson - May 27, 2009 - 21:52
Project:AddThis Button
Version:6.x-2.8
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:fixed
Description

When multiple addthis buttons are on a single page they each come with their own script tag. This patch only includes the tag once in the head.

Not sure you want this one as the code isn't the cleanest, I took the google analytics module approach to workaround the lack of support for external js in drupal_add_js(). Works a treat on my site though as I have an addthis button next to each content item.

AttachmentSize
0001-fix-addthis-to-only-insert-one-script-tag.patch2.62 KB

#1

benpjohnson - November 29, 2009 - 21:14
Version:6.x-2.x-dev» 6.x-2.8

I've updated this patch for 6.28 after finally getting my patch management system in order.

AttachmentSize
addthis-single-javascript-include.patch 2.23 KB

#2

wesku - November 30, 2009 - 20:51
Status:patch (to be ported)» fixed

Thank you for the patch. However we already have a counter variable $_addthis_counter for keeping track on how many buttons we have on a single page. I reimplemented your patch for latest dev version on slightly different way. Some changes are still not quite ready, but I will commit a new version soon.

#3

benpjohnson - December 1, 2009 - 23:40

Great thanks!

One more patch I don't need to worry about :)

 
 

Drupal is a registered trademark of Dries Buytaert.