Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
replace path_get_admin_paths with path_get_tagged_paths
this way a module can turn overlay for certain paths without giving it the admin property as well
currently to turn overlay on, hook_admin_paths must be implemented
which will give the 'admin' property to the path as well, although it was not intended .
Comment | File | Size | Author |
---|---|---|---|
#5 | get_tagged_paths-1220234-2.patch | 19.77 KB | yakoub |
#1 | get_tagged_paths-1220234-1.patch | 11.14 KB | yakoub |
Comments
Comment #1
yakoub CreditAttribution: yakoub commentedattached patch defines new hook : hook_TAG_paths()
so that overlay now may call path_get_tagged_paths('overlay')
and a module requiring the overlay will implement hook_overlay_paths()
Comment #2
yakoub CreditAttribution: yakoub commentedgot the status wrong in first comment
Comment #3
David_Rothstein CreditAttribution: David_Rothstein commentedHm, interesting patch! It could perhaps be useful to generalize the path_get_admin_paths() code in that way, so 'admin' just becomes a special case of it.
In terms of the overlay module, though, I'm not sure what the use case would be for putting a non-admin path in the overlay.... The other way around (having some admin paths that don't appear in the overlay) I can definitely see people wanting, although at a certain point if you're trying to do that it would be better not to use the overlay module at all, rather just jQuery UI dialogs or something. I think the overlay module was pretty much designed to provide a consistent administrative appearance for all admin pages.
Comment #4
yakoub CreditAttribution: yakoub commentedcould you elaborate on " .. designed to provide consistent administrative appearance "
it seemed to me the overlay can easily be turned around to be used for any purpose using hook_admin_paths or hook_admin_paths_alter .
for example you might want to display search results pager inside overlay, or even a lightbox gallery widget
regarding the patch, i took the easy way for creating the new hooks without need to change user_admin_paths and node_admin_paths, but the resulting hook_TAG_paths doesn't have a "good" name
so i am going to attach new patch that replaces all hook_admin_paths implementation in core .
Comment #5
yakoub CreditAttribution: yakoub commentedchanged hook name from hook_TAGGED_paths to hook_tagged_paths
so that overlay for example implements overlay_tagged_paths($tag) instead of overlay_overlay_paths()
Comment #6
David_Rothstein CreditAttribution: David_Rothstein commentedWell, I was just thinking that the overlay module has tons of code (both JavaScript and PHP) whose purpose is to support the full admin experience taking place inside of it. It would be wasteful to load all that (e.g. even for anonymous users) if all you need is a simple lightbox popup. For that use case it would make a lot more sense to use jQuery UI or perhaps something like http://drupal.org/project/dialog instead.
However, if people are already using the overlay for site administration, maybe there are cases where they want to tweak a bit where it appears and make all their site's "overlays" look the same for everyone, so it definitely doesn't hurt to support this kind of flexibility.
Comment #7
yakoub CreditAttribution: yakoub commentedi don't agree the overlay is tons of code, i think it is equivalent of the modal frame and people should be encouraged to use it
it is not as simple to use jquery ui dialog as you describe it, for most cases it will require additional coding which can be reduced by simply using core's overlay
Comment #8
mikey_p CreditAttribution: mikey_p commentedI too am starting to use the overlay for end user facing UI that appears in the site theme (not the admin theme) this is another area where it would be helpful to separate admin paths (which receive the admin theme) from paths that open in the Overlay. For the most part though, I feel that the solution to this is not to use path matching but in my case I'm using some custom JS with classes on certain links to trigger an entry point. The path matching works better for admin pages, but less so for generic Overlay usage. (In my case, it's an commerce site where all product links open the Overlay).
As far as reason to use the overlay, there are tons: It's generally well tested, handles rendering subset of regions, has it's own template, handles back button navigation, and handles form submission (can be problematic in basic lightboxes). If you're requirements are similar it seems like a very obvious solution.
That said, I'm not sure about the patch in this issue, path matching is somewhat limited (I haven't tested to see if it works for aliases) and won't ultimately scale to thousands of paths that some folks may try to (ab)use.
Comment #9
David_Rothstein CreditAttribution: David_Rothstein commented#1412776: Allow Overlay to be used outside admin screens is a related issue. Giving this one a slightly more descriptive title...
Comment #10
RobLoachCould this somehow be managed by hook_menu()? Maybe provide a "overlay path" parameter or something?
Comment #11
c960657 CreditAttribution: c960657 commentedI have marked #1412776: Allow Overlay to be used outside admin screens as a duplicate of this one.
That idea was considered back when the Overlay module was added, but it was abandoned for performance reasons (see comment #416).
I like the generalized approach rather than the duplication of the path logic used in patch in #1412776: Allow Overlay to be used outside admin screens. But I think I prefer hook_TAG_paths() over hook_tagged_paths($tag). The latter reminds me a bit about the $op argument for hook_nodeapi() etc. that was removed in D7.
In my patch I introduced a checkbox on admin/appearance that allows disabling the overlay for admin pages (without disabling the Overlay module). I think we should stick with this idea.
Comment #12
yakoub CreditAttribution: yakoub commentedit is true that every module implementing hook_tagged_paths($tag) will need an "if" structure to check the tag arguments which seems redundant , but i think although less "sophisticated" the "if" emphasize the relation between the module that defines the TAG and the module that defines the which path should be tagged by TAG , so it is better for readability of code and mode simple to use .
for example see the function overlay_tagged_paths in my patch .
Comment #13
yakoub CreditAttribution: yakoub commentedi also first thought of hook_menu when considering this issue and i think it is better implementation .
regarding performance , who said all information from hook_menu should be saved to a router record in menu_router ? the TAG information could be aggregated and saved to one array structure using variable_set
Comment #14
c960657 CreditAttribution: c960657 commentedOkay, let's stick to hook_tagged_paths($tag).
I think the “reference implementation” should use a
switch ($tag)/case/case/...
construct rather than anif/elseif/elseif/...
. This is in line with how hook_nodeapi() was usually made in D6.I prefer not having a default value here.
Instead of foo/non_foo, how about making the keys be the values returned by hook_tagged_paths($tag), i.e. TRUE/FALSE (would map to 1/0) ? This would allow the values to be more than just booleans, i.e. so the $pattern in the code part above could be e.g. array("a" => "node\nuser\nuser/*", 'b' => "admin", "c" => "<front>").
This would mean that the semantics of path_is_tagged() would have to be changed slightly, but I guess we could make some kind of useful logic.
Instead of path_is_tagged(), would path_has_tag() be a better name?
I am wondering whether we could find a better name than “tagged” (to avoid confusion with the tags used in Taxonomy module), but I am out of ideas.
I don't think overlay/dismiss-message is really an admin page. Wouldn't it be more appropriate to mark it as an overlay path?
Comment #15
yakoub CreditAttribution: yakoub commentedgenerally i tried to preserve the original code logic as much as possible, this is why i didn't change the tagged paths array structure since that will require changing other overlay code .
you can off course suggest your own patch after making sure it passes the tests .
Comment #15.0
yakoub CreditAttribution: yakoub commentedrephrase description
Comment #16
nod_Overlay is dead to D8 #2088121: Remove Overlay.
Comment #17
nod_Sorry actually wanted to do that instead. Got too enthusiastic for a moment :D