Dear Drupalers,
I tried to implement the overlay on additional non-administrative pages with
the hook_admin_paths_alter().

But the following code lets the overlay close immediately on the path "custom".

function myModule_admin_paths_alter(&$paths) {
  // Treat all user pages as administrative.
  $paths['custom'] = TRUE;
  $paths['custom/*'] = TRUE;
}

Is there any chance to enable the overlay on custom ("administrative") paths?

Kind regards and keep on rocking!

Matthias

Comments

Smudio’s picture

Category: feature » bug
casey’s picture

Category: bug » support
Status: Active » Fixed

It should work. Did you clear Drupal cache?

casey’s picture

Category: support » bug
Status: Fixed » Active

oops

Smudio’s picture

Thanks for the response, casey,

I cleared the caches, does not work unfortunately...

David_Rothstein’s picture

Code similar to the above does work fine for me. Maybe you can post a larger section of your code?

Note that it is only expected to open in the overlay if you click on a link to it in the site or visit it by URL with something like http://example.com/#overlay=custom. If you go to http://example.com/custom directly, it won't open in the overlay (by design, although I think that is problematic in some ways). It sounds like that is probably not your issue, but thought I'd mention it in case it is.

Smudio’s picture

Hi David,

could you post your sample code since I tried to implement hook_admin_paths() and hook_admin_paths_alter() in a variety of ways... ?

I had created menu items, but the overlay opens and closes immediately on the specified paths.

Do I miss anything when writing a custom module which only contains the code above in a .module file and an .info file?

Thanks,

Matthias

David_Rothstein’s picture

In sites/all/modules/mymodule, if I put mymodule.info with:

name = My Module
core = 7.x
files[] = mymodule.module

and mymodule.module with

/**
 * Implements hook_menu().
 */
function mymodule_menu() {
  $items['custom'] = array(
    'title' => 'Custom',
    'page callback' => 'mymodule_custom_page',
    'access callback' => TRUE,
  );

  return $items;
}

function mymodule_custom_page() {
  return t('This is a test.');
}

/**
 * Implements hook_admin_paths().
 */
function mymodule_admin_paths() {
  $paths['custom'] = TRUE;
  return $paths;
}

/**
 * Implements hook_admin_paths_alter().
 */
function mymodule_admin_paths_alter(&$paths) {
  $paths['user'] = TRUE;
  $paths['user/*'] = TRUE;
}

it all seems to work fine - clicking on the new 'Custom' link in the navigation menu, as well as any user-related links, takes me into the overlay when I am logged in as an administrator.

Is it possible you forgot to define the page callback for your menu item? If I remove the mymodule_custom_page() function above, I get some weird behavior similar to what you are describing... so I wonder if that could be it.

Hope that helps!

Smudio’s picture

Status: Active » Fixed

Hi David,

yes, that was it ;-)

Thanks a lot, especially for showing the sample code!

Greetings from Berlin! Matthias

Status: Fixed » Closed (fixed)
Issue tags: -overlay hook_admin_paths_alter() custom administrative paths

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

tmsss’s picture

Hi there! I'm trying to load a node directly into overlay from a view link but I get the same weird behavior described by David and the page gets redirected to the node page instead of opening the overlay.

Here is my code:

/**
 * Implements hook_menu().
 */
function restylr_helper_menu() {
  $items['item/%node'] = array(
    'page arguments' => array(1),
    'page callback' => 'item_overlay_page',
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}
function item_overlay_page($node) {
  
  $contents = node_view($node, 'full');
  $output = drupal_render($contents);

  return $output;
}
/**
 * Implements hook_admin_paths().
 */
function restylr_helper_admin_paths() {
  $paths['item/*'] = TRUE;
  return $paths;
}
/**
 * Implements hook_admin_paths_alter().
 */
function restylr_helper_admin_paths_alter(&$paths) {
  $paths['item'] = TRUE;
  $paths['item/*'] = TRUE;
  $paths['item/*/view'] = TRUE;
  $paths['item/*/edit'] = TRUE;
}

Can you help me out?