2

Is there a built in or module way to add menu items with hook_menu to serve as containers, not links? I have a module set. Main module provides central configuration and satellite modules do actual work. main module should create submenu satellite modules will use to add their entries to, but there is no form nor page to put in the main element. Is there a way to avoid dummy content?

I want to avoid editing template.php - I use theme downloaded from drupal.org and I don't feel creating a subtheme to get that is really worth the effort - there should be an easier way, shouldn't it?

I know there are ways to do this with Menu UI, but I need it to work out of the box for my clients, so UI is not an answer.

0

1 Answer 1

1

I'm not sure how you'd get exactly that to work with the way Drupal's menus are structured.

Core provides a barebones page callback for handling the same sort of situation itself, the system_admin_menu_block_page() function. All it does for the page display is list the menu items that are underneath it in the hierarchy (like the node/add page). Think of it as a landing page for a menu item that doesn't need any other form/page data.

I believe if there are no sub-items under the parent, the menu link won't actually be displayed so that method should get you pretty close.

$items['admin/something'] = array(
  'title' => 'Something',
  'access arguments' => array('some permission'),
  'page callback' => 'system_admin_menu_block_page',
  'file' => 'system.admin.inc',
  'file path' => drupal_get_path('module', 'system'),
);

Then your other module can define paths like 'admin/something/something-else' and they'll appear underneath the parent

3
  • Forget my earlier comments, couple of cache clears (not only menu) and it works like a charm. I will not accept it for now, as it is (great) workaround but not what I think I need. Upvoted none the less.
    – Mołot
    Jun 5, 2013 at 11:14
  • You could always implement hook_theme_registry_alter() and replace the function used for theme_menu_item_link() with a custom one. That would have the same effect but you can keep the logic in your module
    – Clive
    Jun 5, 2013 at 18:02
  • Now that sounds tempting :) Gotta try.
    – Mołot
    Jun 5, 2013 at 18:10

Your Answer

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

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