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.
Is it just me, or does it seem to others that top-level 'admin' items such as 'Content management' and 'Site building' should not appear in the menu at all when there are no child items?
I've accomplished this successfully by altering admin_menu_tree_output() to omit an item if 'plid' == 0 && 'link_path' begins with 'admin'. Also looked at _admin_menu_rebuild_links() but thought it might be more resource-intensive to pull the needed data for each item from {menu_links} in order to check for children.
Comment | File | Size | Author |
---|---|---|---|
#6 | admin_menu.categories.6.patch | 3.38 KB | sun |
Comments
Comment #1
Ellen Dee CreditAttribution: Ellen Dee commentedIn case it isn't *just* me...
Here's a non-hacky way to hide these menu items, below. Issues may arise if admin_menu's external javascript doesn't load up before this is called-- my understanding is that $(document).ready() doesn't check external scripts-- but so far works fine for me.
** Note that hook_footer() is deprecated in Drupal 7. Not sure, but you might want to use hook_page_alter() as an alternative in D7.
Module code:
... or just insert near the bottom of page.tpl.php:
Comment #2
sunThis is prominently covered on the project page, and caused by a Drupal core bug: #296693: Restrict access to empty top level administration pages
Comment #3
hanoiiJust bringing this one to life a bit.
On D7, the normal administration screens do not show the empty items, but they do show on the admin_menu, is this a bug on D7 as well or is something that might be done on admin_menu?
Comment #4
hanoiiOk, the high level admin categories do remain even as empty. But admin_menu is also showing sub items that should not be there really, as they not appear in the admin pages.
For instance, all of the configuration subitems are there, eventhough I only have access to one.
Comment #5
sunComment #6
sunPasses for me.
Comment #7
sunThanks for reporting, reviewing, and testing! Committed to all branches.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.