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 .

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yakoub’s picture

attached 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()

yakoub’s picture

Status: Patch (to be ported) » Needs review

got the status wrong in first comment

David_Rothstein’s picture

Version: 7.x-dev » 8.x-dev

Hm, 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.

yakoub’s picture

could 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 .

yakoub’s picture

changed 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()

David_Rothstein’s picture

could 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

Well, 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.

yakoub’s picture

i 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

mikey_p’s picture

Status: Needs review » Needs work

I 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.

David_Rothstein’s picture

Title: using path_get_tagged_paths » Introduce path_get_tagged_paths, and allow the overlay to be used on non-admin pages

#1412776: Allow Overlay to be used outside admin screens is a related issue. Giving this one a slightly more descriptive title...

RobLoach’s picture

Could this somehow be managed by hook_menu()? Maybe provide a "overlay path" parameter or something?

c960657’s picture

I have marked #1412776: Allow Overlay to be used outside admin screens as a duplicate of this one.

Could this somehow be managed by hook_menu()? Maybe provide a "overlay path" parameter or something?

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.

yakoub’s picture

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.

it 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 .

yakoub’s picture

Could this somehow be managed by hook_menu()? Maybe provide a "overlay path" parameter or something?

That idea was considered back when the Overlay module was added, but it was abandoned for performance reasons (see comment #416).

i 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

c960657’s picture

Okay, let's stick to hook_tagged_paths($tag).

I think the “reference implementation” should use a switch ($tag)/case/case/... construct rather than an if/elseif/elseif/.... This is in line with how hook_nodeapi() was usually made in D6.

+function path_get_tagged_paths($tag = 'admin') {

I prefer not having a default value here.

-    $patterns['admin'] = implode("\n", $patterns['admin']);
-    $patterns['non_admin'] = implode("\n", $patterns['non_admin']);
+    $patterns[$tag] = implode("\n", $patterns[$tag]);
+    $patterns['non_' . $tag] = implode("\n", $patterns['non_' . $tag]);

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.

+  if ($tag == 'admin') {
+    $paths = array(
+      // This is marked as an administrative path so that if it is visited from
+      // within the overlay, the user will stay within the overlay while the
+      // callback is being processed.
+      'overlay/dismiss-message' => TRUE,
+    );
+    return $paths;
+  }

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?

yakoub’s picture

generally 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 .

yakoub’s picture

Issue summary: View changes

rephrase description

nod_’s picture

Version: 8.x-dev » 7.x-dev
Issue summary: View changes

Overlay is dead to D8 #2088121: Remove Overlay.

nod_’s picture

Version: 7.x-dev » 8.x-dev
Component: overlay.module » base system

Sorry actually wanted to do that instead. Got too enthusiastic for a moment :D

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.