I might be missing something but I have the following problem. I placed the following code for the toolbox in page.tpl:

print theme('addthis_toolbox', 'twitter, linkedin, google_plusone, share_compact');

When I'm viewing a node, the buttons show ok.
When I'm viewing other pages (not nodes) the buttons don't show (like the js is not running).
I tried to invoke the addthis supplied block using the following code (after setting the services in the admin page):

$block = (object) module_invoke('addthis', 'block', 'view', '0');
print theme('block',$block);

I get the same problem. The buttons only show on nodes.
Now it gets more strange. If I set the addthis block to show on any region (via admin/build/block), the buttons in the block are showing ok but also the buttons in my code are showing ok (on all pages).
What am I missing?

Comments

d.clarke’s picture

The problem is more than likely that the addthis JS library that is included in the page template $head variable isn't present on your pages that aren't working. Without knowing more specifics, my guess is that you are putting the code snippets you provided in a page template, hook_preprocess_page, or some other place that happens after drupal_get_html_head() is called. While this might not be correct usage, you can work around this issue by re-assigning the
$vars['head'] = drupal_get_html_head();
in your hook_preprocess_page() after you've made your "theme('addthis_toolbox...." calls. There is likely a better way to do this, but without knowing more this should at least get it working for you.

gisle’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This support request is 3 years old and is about a version of the module that is no longer supported.

I hope it has been resolved by now, but ver. 6.x-3.x is under any circumstance no longer supported, so I am closing.

Feel free to reopen this is still relevant to you and applies to a supported version of AddThis (e.g 7.x-4.x).