There seems to be a recent change to the AddThis JS that results in the share buttons failing to display. This thread on their forum talks a little bit about it:

http://www.addthis.com/forum/viewtopic.php?f=4&t=33111

As noted there, the workaround is to move the AddThis JS out of the head and into the body. Right now, the module uses drupal_set_html_head() to add a

tag to the document head. I'm not sure how to move it into the body; perhaps addthis_preprocess_page() could append it to the page content?

Comments

najyk’s picture

Subscribing. Hopefully someone can solve this soon!

najyk’s picture

Priority: Normal » Critical

I would also set this as critical, as it renders the module completely inoperable.

les lim’s picture

I can't quite figure out the nature of this bug from the AddThis.com forum report you specified. The share widgets appear to be working fine on my own websites - the JS file is lazy-loaded and initialized from the bottom of the BODY element, so I wonder if that shouldn't already cover this.

What site are you experiencing this on?

Alessandro Pezzato’s picture

BrockBoland’s picture

I don't think it's related to that other issue: the code is there, but the buttons aren't loading. In particular, this is happening on a page displaying a View block that has the Node: AddThis toolbox field.

One of the devs I work with got around it by hacking the module to make it work for now. We removed this whole block:

  // If javascript caching is enabled and the private file system is not being
  // used, go ahead and load the cached file.
  if (variable_get('addthis_cache_js', 0) && variable_get('file_downloads', 1) == 1 && $source = addthis_cache_js('http://s7.addthis.com/js/250/addthis_widget.js')) {
    // We need the async fragment in the src argument, so we can't use
    // drupal_add_js() so far as I know.
    drupal_set_html_head("<script type='text/javascript' src='" . base_path() . $source . "#async=1'></script>");
  }
  else {
    // Load the external javascript in the head.
    drupal_set_html_head("<script type='text/javascript' src='http://s7.addthis.com/js/250/addthis_widget.js#async=1'></script>");
  }

And added this to addthis_footer():

drupal_add_js('http://s7.addthis.com/js/250/addthis_widget.js#async=1', 'external', 'footer');
les lim’s picture

Status: Active » Postponed (maintainer needs more info)

I can't reproduce this bug. If someone could point me to a URL for a site that's experiencing this or tell me steps to reproduce, that would be helpful.

stu1984’s picture

I believe this issue is occurring on one of the sites I maintain. An example of where it isn't working can be found here: http://www.itvbabysign.com/about-itv-babysign.

The AddThis block appears to work on my homepage, which uses panels, however it has disappeared on every other page. I haven't made any changes, they just disappeared one day, which is why I think it is related to the issue of the Javascript code being changed by AddThis. Any help would be greatly appreciated thanks.

BrockBoland’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new1.49 KB

The attached is an incomplete patch. Don't apply it to your production site and expect it to work - we're still trying to determine whether or not there's anything to be fixed.

That being said, stu1984, could you apply this patch to your site and see if it works :-P This is what we did to fix ours, though it removes the addthis_cache_js check so it's not a complete solution.

You can see it working on the Amnesty USA site: http://www.amnestyusa.org/news/press-releases/amnesty-international-call...

stu1984’s picture

Thanks for letting me be the guinea pig for this fix ;-) Thankfully we have an internal dev version of the site which is exactly same and was suffering the same issue, so I used that instead. Initially when I applied the fix it brought the whole site down (execution times suddenly increased beyond the 60 second limit). However I tried playing with updated code and found that the problem lay with this line:

drupal_add_js('http://s7.addthis.com/js/250/addthis_widget.js#async=1', 'external', 'footer');

Changing it to the following allowed the site to work and the AddThis buttons came back on all pages:

drupal_add_js('/s7.addthis.com/js/250/addthis_widget.js#async=1', 'external', 'footer');

After reading about the drupal_add_js function I guess it was adding an extra leading slash, as it creates a path relative to the base path. This would mean it was originally trying to access a file at '/http://s7.addthis.com/js/250/addthis_widget.js#async=1' which wouldn't work. I'm not sure how this worked on your site, maybe a server configuration or something like that. Hopefully now we have a starting point to get this issue sorted.

stu1984’s picture

StatusFileSize
new1.48 KB

Here is the edited patch file.

stu1984’s picture

StatusFileSize
new1.5 KB

Found an issue with the previous patch can occur if the Javascript caching option is enabled in the 'Performance' section of the site, as it will try to optimize the file which causes problems. Adjusted code so that this is not an issue.

ericclaeren’s picture

Thanks, had a problem with a disappearing like button, this patch did the trick for me.

http://drupal.org/node/1231636#comment-4807098

les lim’s picture

Version: 6.x-3.0-beta1 » 6.x-3.x-dev
Priority: Critical » Major
Status: Active » Fixed

I committed a fix just now that moves the AddThis script execution to the footer. It should be repackaged as the latest 6.x-3.x-dev version with an August 5 date.

@stu1984: Unfortunately, drupal_add_js() can't be used that way officially, since it won't work if your base_path is anything other than "/".

stu1984’s picture

@Les Lim: Thanks for creating a proper fix for this issue. Knew that the fix I uploaded was a bit rough, but it was just to get something working until someone with a bit more knowledge of how this module worked came along. Had a look at your solution and now have a better idea where I went wrong.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.