1

I'm doing my first drupal module (webform extension) and I have a problem with the overlay when editing a webform.

I added the "Factors" tab in my hook_menu():

Webforms tabs

$items['node/%webform_menu/webform-factors'] = array(
    'title' => 'Factors',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('forms_grade_factors_create_factor'),
    'access callback' => 'user_access',
    'access arguments' => array('access administration pages'),
    'weight' => 5,
    'type' => MENU_LOCAL_TASK,
  );

But when I click on this Factor tab, the overlay disappears:

Overlay broken

I don't know if it's important, but when I click on the other webform tabs, their urls are something like this:

drupal.dev/node/12#overlay=node/12/grant

And my module:

drupal.dev/node/12/webform-factors#overlay-context=node/12

How can I keep the overlay layer? Thanks a lot!

EDIT:

I also implemented hook_admin_paths:

function webform_factors_admin_paths() {
  return array(
    'node/*/webform-factors' => TRUE,
    'node/*/webform-factors/*' => TRUE,
  );
}

1 Answer 1

0

The overlay automatically applies to paths that Drupal recognizes as being 'administrative'. That's always the case for paths that start with "admin", for example.

For custom node tabs, however, you'll need to implement hook_admin_paths() to register your custom path pattern:

<?php
function hook_admin_paths() {
  $paths = array(
    'node/*/webform-factors' => TRUE,
  );
  return $paths;
}
?>
3
  • Hi Les Lim. Thank you for your answer. I forgort to paste that function. I've just edited my question. Not works with that hook. :(
    – ecurbelo
    Commented Sep 2, 2015 at 8:24
  • That should be all you need. When you visit that path, does the page render with your administration theme? If not, then your hook implementation might not be running.
    – Les Lim
    Commented Sep 2, 2015 at 16:45
  • I found the error! It's like you said. Recently I renamed the module, the hook_admin_paths had the old name and to make it work, I changed it and I had to uninstall and reinstall the module. Thank you so much!! :)
    – ecurbelo
    Commented Sep 3, 2015 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.