The overlay can be made reusable very simply by skipping its own initialization if some other module already did the overlay setup. This can be used to disable / enable the overlay in creative way without intervening with overlay's own code.

A very simple change makes this possible. Just check in overlay_init() whether we have an overlay mode set already. If we do, then we can just skip our own initialization.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Status: Active » Needs review
FileSize
3.54 KB

This makes sense, although some of that is there already, right? (Since overlay_set_mode() already only works the first time you call it...) But I guess this patch would also prevent some of the stuff that's hardcoded into overlay_init() from running as well. It's not totally clear to me what the boundary is between code that belongs inside overlay_init() and code that belongs inside overlay_set_mode() itself.

Anyway, here is an updated patch that fixes a typo in the code comment and also tries to rewrite and expand the code comments for overlay_set_mode() to explain more how other modules can actually enable/disable the overlay. I think it might still need a bit more work, though.

Gábor Hojtsy’s picture

New patch is the same approach that I did above but has added comments on how useful it is :) I think its great. Since it is mostly a docs/typo change, I don't feel empowered to RTBC it, since it feels like RTBC-ing my own patch :)

ksenzee’s picture

Status: Needs review » Reviewed & tested by the community

Looks great to me. Probably overlay_init() and overlay_set_mode() could largely be combined, but that's an issue for another day.

klausi’s picture

Status: Reviewed & tested by the community » Needs work
+++ modules/overlay/overlay.module	20 Mar 2010 17:22:57 -0000
@@ -56,9 +56,12 @@ function overlay_permission() {
-  if (user_access('access overlay')) {
+  ¶
+  $mode = overlay_get_mode();

trailing whitespace

Powered by Dreditor.

aspilicious’s picture

Status: Needs work » Needs review

#1: overlay-check-mode-743908-1.patch queued for re-testing.

aspilicious’s picture

Think this needs a reroll

Status: Needs review » Needs work

The last submitted patch, overlay-check-mode-743908-1.patch, failed testing.

casey’s picture

Status: Needs work » Needs review
FileSize
3.39 KB

Reroll.

ksenzee’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the reroll casey. Still looks good and tests fine.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Looks good, and thanks for the extra information. Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

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