Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I've turned on the cacheing on a Drupal site that has AddToAny Module installed. The strangest thing happens that on the first page load after the cache is cleared the popup works fine but on the fallowing loadings of the page the popup just doesn't appears anymore. I checked the source of the page and it apperas that the script that creates the box is not inserted anymore.
Comments
Comment #1
micropat CreditAttribution: micropat commentedNo other reports, and cannot reproduce yet. What are your settings in admin/config/development/performance?
Comment #2
ace11 CreditAttribution: ace11 commentedThis happens to mee too. Very strange behavior.
And also noticed that this same thing happens with 7.x-4.0 version.
Comment #3
ezman CreditAttribution: ezman commentedI am seeing this too with 7.x-4.0
Performance settings are all checkboxes checked and dropdowns have 'none' selected.
If I clear all caches then the anonymous user can see the popup on the first page requested. Other pages do not show the popup. Revisiting the first page shows the popup.
I tried manually adding the script that creates the da2a object to my theme's script.js. The error in the javascript console about da2a not being defined goes away, but the popup still does not display.
Unchecking 'aggregate javascript files' does not fix the issue.
Unchecking 'cache blocks' appears to fix this issue for me. My AddToAny popup is in a block.
Comment #4
AshleyWilde69 CreditAttribution: AshleyWilde69 commentedI also have the block randomly disappearing. One minute its there the next its not displayed. Refresh and its there again. Then gone on the next page. Very frustrating.
Ashley :)
Comment #5
tim_djI've a similar problem. I have two addtoany blocks. One is added in a View. The other is normal addtoany block inserted through contexts.
When I clear text they are both visible. After that the bottom one is missing (the one inserted through context) using 7.x-4.5
Comment #6
tim_djI've figured out what my problem was. I had views cache. Output and query cache where on 5 minutes. This means the output of _addtoany_create_button() gets cached. Which causes it only to work after emptying cache because it won't execute the code in _addtoany_create_button() again with cache.
Comment #7
emilflatz CreditAttribution: emilflatz commentedAddToAny block disappeared when I enabled cache block option in performance settings.
I installed Block Cache Alter, and on the block list page disabled the cache on AddToAny block.
Block reappeared again.
Comment #8
tim_djJavascript and css should be attached to block using #attached instead of doing it with drupal_add_js otherwise they won't be reloaded when block is in cache.
Comment #9
Shane Birley CreditAttribution: Shane Birley commentedConfirmed. Cache turned on, block disappears. Cache turned off either via Drupal performance or via Block Cache Alter it appears.
Comment #10
micropat CreditAttribution: micropat commentedSwitched to
#attached
as part of today's dev release.Please try it and report back!
Comment #11
micropat CreditAttribution: micropat commentedShould be fixed in 7.x-4.6 since
drupal_add_
functions are replaced with#attached
.Comment #13
Shane Birley CreditAttribution: Shane Birley commentedConfirmed.
Comment #14
jamix CreditAttribution: jamix commentedUsing 7.x-4.6 over here and the problem still exists. FYI,
#attached
still works viadrupal_add_
under the hood.Comment #15
robertragas CreditAttribution: robertragas commentedYeah, I had the same problem. What I did was use hook_block_info_alter to turn off the caching for the addtoany block and then it worked.
Maybe just turn off the caching in the hook_block_info? Not sure if it would impact performance alot.
Comment #16
emanuelrighetto CreditAttribution: emanuelrighetto commented@Robert Ragas is right. And also his implementation of hook_block_info_alter() solves the problem of inline script when caching is on.
Comment #17
russellb CreditAttribution: russellb as a volunteer commented+1 for switching off the block cache on the add to any block
#15 is solving this for me so far
Comment #18
caspervoogt CreditAttribution: caspervoogt at Plethora commentedConfirming this issue for 7.x-4.7 as well, and Robert's code solves it, though I think the Add To Any module's addtoany_block_view function should be adjusted to include the renderable array including CSS and JS, rather than using addtoany_page_alter() to attach the CSS/JS, no?
e.g.;
Comment #20
micropat CreditAttribution: micropat commentedVersion 7.x-4.8 turns off caching on AddToAny blocks to resolve this issue.