The drupal_add_js() function is never called a sencond time in a block function if block caching is enabled. This result in the JavaScript settings not being output after the block is cached.

The following issues are similar to this one:

Currently, the only fix is to make the block non-cacheable, which can be accomplished by adding the following line to the addthis_block() hook:

   $blocks[0]['cache'] = BLOCK_NO_CACHE;

Notice that this change may not take effect on already created blocks due to a bug in core (see #235673: Changes to block caching mode not caught). To make the change on already created blocks, run the following SQL on your database:

update blocks set cache = -1 where module = 'addthis';

Comments

jjchinquist’s picture

Adding the CSS and JS commands inside of hook_init should fix this problem. Of course, now you are adding the CSS and JS to the top or footer of all pages and not just those pages the block is initiated on.

Working on testing a patch now.

vesapalmu’s picture

Status: Active » Needs work

Any news on the patch? This could be a tricky issue to fix. Sounds a bit like overkill to add CSS + JS to hook_init in a module like this. I am trying to keep the module as light weight as possible so that it could also be used on large sites.

vesapalmu’s picture

Priority: Critical » Normal

Any news on this? This doesn't seem to be a major issue at the moment.

hanskuiters’s picture

It IS an issue when your using cache. I can confirm the patch works against 6.x-3.0-beta1

LostReaper’s picture

oh does this cause addthis block not appearing at all? I have that issue, when I logged in as admin I see the block in everywhere but whenever I log out block sometimes appears on pages. if this is the issue, simply flushing all caches fixes it?

thx

www.esguide.org

lpalgarvio’s picture

+1

les lim’s picture

Status: Needs work » Fixed

Fixed in 6.x-3.0-beta2. This will not be backported to 6.x-2.x.

Status: Fixed » Closed (fixed)

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