After installing the latest dev version for ubercart, I noticed that admin_menu added menu items for the store configuration section under ->ICON->Administer.
After deleting all admin menu items from the menu links table, and rebuilding the menu, I noticed that the store configuration section was now under ->Store configuration, which is where i expected it to be, and where I was trying to get it to appear.
I have a feeling this happens because initially, there is an menu item with path 'admin', which causes admin menu to link any newly added admin/* paths to the administer link, instead of setting their parent to be as might be otherwise expected.
Was it by design that any new paths directly under admin get placed under the Administer link, or are they supposed to appear in the root of the menu? To me the root seems most logical.
As a simple test case/steps to reproduce:
- Add the code below to hook_menu of admin_menu
$items['admin/test'] = array( 'title' => 'Test Menu Item', 'description' => 'Testing, 1 2.', 'position' => 'right', 'weight' => -50, 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', 'file path' => drupal_get_path('module', 'system'), ); $items['admin/test/something'] = array( 'title' => 'Something', 'description' => 'Sub menu item 1.', 'page callback' => 'drupal_not_found', 'access arguments' => array('access administration pages'), ); $items['admin/test/nothing'] = array( 'title' => 'Nothing', 'description' => 'Another sub menu item', 'page callback' => 'drupal_not_found', 'access arguments' => array('access administration pages'), ); - Visit /admin/build/modules to have the new items picked up.
- Note that the new items have been added under ICON->Administer
- Go into the database, and run the following SQL:
DELETE FROM `menu_links` WHERE `menu_name` = 'admin_menu'; - Visit /admin/build/modules again
- Note that now, there is a new root menu item titled 'Test Menu Item'
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | admin_menu-DRUPAL-6--1.administer.patch | 766 bytes | sun |
Comments
Comment #1
sunOf course, all links below admin/ should be added to the root level and not below that "Administer" item.
What if we remove that "Administer" item completely from admin_menu? To be honest, I have never used it, because that page does contain valuable stuff anyway...
Comment #2
cdale commentedThat does work of course. When i wrote this I was trying to find a less 'destructive' solution, as there is potentially someone that likes that 'Administer' link, although again, I don't recall ever having used it.
My thought was it might be possible to explicitly set the parent path to <root> if the parent path was equal to 'admin' and there were only 2 parts to the menu item. I thought this might have been possible in the
admin_menu_link_buildfunction, but was not 100% sure if this was a sound idea or not.I was imagining using something like the following in
admin_menu_link_build:Of course, this then messes up the 'by-module' link. To stop that from happening, I suppose the above code could be placed around line 28 of admin_menu.inc. Just above the call to
admin_menu_link_save($item);inside the for each there.Does what I've said make any sense? Does it seem like an OK idea?
Comment #3
sunActually, removing the 'Administer' item fixes not only this bug, but also uncovers errors in DAM that are unrelated to this issue.
A quick poll in IRC confirmed that no one is using this item.
Committed attached patch.