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:
- #351214: Unable to see banners when block cache is enabled
- #342459: Block cache problem (Not showing for anonymous or authenticated users)
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
Comment #1
jjchinquistAdding 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.
Comment #2
vesapalmu commentedAny 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.
Comment #3
vesapalmu commentedAny news on this? This doesn't seem to be a major issue at the moment.
Comment #4
hanskuiters commentedIt IS an issue when your using cache. I can confirm the patch works against 6.x-3.0-beta1
Comment #5
LostReaper commentedoh 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
Comment #6
lpalgarvio commented+1
Comment #7
les limFixed in 6.x-3.0-beta2. This will not be backported to 6.x-2.x.