We use modalframes for popups. Modalframes draw a new page inside an iframe. This was problematic because it gave us a second olark chat box inside the modal. Using contexts in this case seemed kludgey.
To fix this I've implemented hook_suppress in olark. Patch to follow. This hook doesn't follow convention at all, so I'm going to be a little more verbose here than would usually be necessary. It was originally a part of admin_menu, used for hiding the menu in certain situations but a few other modules have started picking it up too. (http://drupal.org/node/249537)
hook_suppress is responsible for checking and setting a static variable which serves as a flag for whether or not to display certain blocks. The code is virtually the same for any module that implements it. Modules that are suppressible are responsible for calling their own suppress hook to find out if they should display or not. In this case I added it to olark_footer in the same conditional where olark_enable is checked.
Other modules (in my case, modalframe) are responsible for calling module_invoke_all('suppress') when they deem it necessary to hide suppressible content. So, defining and checking hook_suppress basically opts your module in to have its block excluded in certain conditions.
Comment | File | Size | Author |
---|---|---|---|
#4 | olark-hook_suppress-1418930-4.patch | 1.4 KB | jsagotsky |
#1 | olark-hook_suppress-1418930-1.patch | 6.05 KB | jsagotsky |
Comments
Comment #1
jsagotsky CreditAttribution: jsagotsky commentedHere's the patch.
Comment #2
iler CreditAttribution: iler commentedComment #3
iler CreditAttribution: iler commentedThis patch either isn't done against the latest dev version or it removes the hook_init. Could you please redo the patch so it doesn't remove the hook_init. The hook_init is there to fix the bug where the settings and olark.js where not inserted.
Comment #4
jsagotsky CreditAttribution: jsagotsky commentedMy sources were out of date. Sorry about that.
Comment #5
iler CreditAttribution: iler commentedTested, reviewed and pushed to dev branch.