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:

  1. 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'),
      );
    
  2. Visit /admin/build/modules to have the new items picked up.
  3. Note that the new items have been added under ICON->Administer
  4. Go into the database, and run the following SQL:
    DELETE FROM `menu_links` WHERE `menu_name` = 'admin_menu';
  5. Visit /admin/build/modules again
  6. Note that now, there is a new root menu item titled 'Test Menu Item'
CommentFileSizeAuthor
#1 admin_menu-DRUPAL-6--1.administer.patch766 bytessun

Comments

sun’s picture

Status: Active » Needs review
StatusFileSize
new766 bytes

Of 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...

cdale’s picture

That 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_build function, 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:

  if (isset($item['_parts'][0]) && $item['_parts'][0] == 'admin' && count($item['_parts']) == 2) {
    $item['parent_path'] = '<root>';
  }

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?

sun’s picture

Status: Needs review » Fixed

Actually, 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.

Status: Fixed » Closed (fixed)

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