Both task and index are next to useless nearly all the time, and on small screens, they're just a waste of space, and the extra items in the menu just make it harder and more confusing to see what else is available.

I can see that both of these items must be useful in some cases, but those cases would be few enough that putting these items under the icon wouldn't cause significant disruption.

Comments

pfrenssen’s picture

I would even suggest to remove these two menu items altogether.

jason.fisher’s picture

This can be done through hook_admin_menu_output_alter(&$content):


**
 * Alter content in Administration menu bar before it is rendered.
 *
 * @param $content
 *   A structured array suitable for drupal_render(), at the very least
 *   containing the keys 'menu' and 'links'.  Most implementations likely want
 *   to alter or add to 'links'.
 *
 * $content['menu'] contains the HTML representation of the 'admin_menu' menu
 * tree.
 * @see admin_menu_menu_alter()
 *
 * $content['links'] contains additional top-level links in the Administration
 * menu, such as the icon menu or the logout link. You can add more items here
 * or play with the #weight attribute to customize them.
 * @see theme_admin_menu_links()
 * @see admin_menu_links_icon()
 * @see admin_menu_links_user()
 */
function MODULE_NAME_admin_menu_output_alter(&$content) {
  
  $admin_menu_exclusions = array(
    t('Tasks'),
    t('Index'),
  );
  
  foreach($content['menu'] as $menu_key => $menu_tree) {
    if (in_array($menu_tree['#title'], $admin_menu_exclusions))
      unset($content['menu'][$menu_key]);
  }

}

pfrenssen’s picture

Thanks, that solves it. Very nice that Admin Menu is fully customizable now!

mstrelan’s picture

Thanks jason.fisher

If you want to move the items under the icon menu they can with this code:

<?php
/**
 * Implements hook_admin_menu_output_alter().
 */
function MYMODULE_admin_menu_output_alter(&$content) {
  // Move Tasks and Index under the icon menu.
  foreach ($content['menu'] as $key => $menu_item) {
    if ($menu_item['#href'] == 'admin/tasks' || $menu_item['#href'] == 'admin/index') {
      $menu_item['#weight'] = -50;
      $content['icon']['icon'][$menu_item['#href']] = $menu_item;
      unset($content['menu'][$key]);
    }
  }
}
?>
geerlingguy’s picture

Thanks for the code in #2 - very helpful!

tsvenson’s picture

Agree that they should be taken off the toolbar and moved to the icon menu.

Maybe an option in the settings for letting users opt to move them or leave them where they are would be a good way of conforming with the core structure.

dalin’s picture

Issue tags: +Usability

In addition, the words "Index" and "Tasks" are very vague. Especially for someone new to Drupal seeing these two words as the first ones in the menu is utterly confusing. This is an example of the many times in Drupal that we are too reliant on abstract nouns. In addition to moving these items under the icon menu I recommend renaming them to "Configure by module" and "Administration categories". I don't see the need to clutter the admin UI with settings for where to have them - if someone wants to move them out from under the icon menu they can do so with the techniques listed above.

dalin’s picture

Status: Active » Needs review
StatusFileSize
new1007 bytes

Ugh, these are the names that Drupal Core has defined, it's not related to Admin Menu. Well those aren't going to be changed in D7, so we can change them in Admin Menu, and file a core bug for D8.

sun’s picture

Macronomicus’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #8 Is the perfect fix!
Cheers!

itangalo’s picture

+1 for this patch. Really helps my 800x600 presentations.

gratefulsk’s picture

Patch in #8 works great!

davemybes’s picture

Adding my name to the list of +1 for the #8 patch.

axe312’s picture

#8 works perfect with 7.x-3.0-rc1 :)

Courtney.B’s picture

Loves it! Patch in #8 worked w/ 7.x-3.0-rc1.

jenlampton’s picture

Patch in #8 still applies cleanly to 3x-dev as well

sun’s picture

Title: Move "task" and "index" under icon » "Tasks" and "Index" links appear on the top-level
Category: feature » bug
Status: Reviewed & tested by the community » Needs review
Issue tags: -Usability
StatusFileSize
new474 bytes

These tasks/links were originally simply removed instead of relocated. The code for that is merely outdated.

Was there any particular reason for keeping them around?

dalin’s picture

I find the index sometimes useful in cases where I've installed an unfamiliar module, and the module's config pages are in a non-obvious spot.

naught101’s picture

I agree with dalin. Index is useful. Tasks is not. Perhaps index should be altered back to "Administration by module", or just to "admin index"

jenlampton’s picture

Status: Needs review » Reviewed & tested by the community

I don't find either of them useful, and would love to see them both gone :)

itangalo’s picture

I agree with jenlampton. But maybe an option on the admin menu settings page to choose for yourself?

pfrenssen’s picture

Well, if you would need this menu item (or any other for that matter), you can put them in with the hook_admin_menu_output_alter() :)

dalin’s picture

While I find the index mildly useful I'm not in favour of a config option. If someone like myself would like to keep the menu item I'd rather that a hook be used.

sun’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.17 KB

Alright, different approach - let's move them instead.

This patch makes pretty clear that we need to do something about #821128: Ensure reliable link structure and contents for alter hooks (to not break on customizations), so I elevated that issue.

dalin’s picture

@sun are you opposed to renaming them to something more understandable like the patch in #8?

sun’s picture

yeah... I don't think that makes them any more clear - they're sorta in line with the surrounding links, which equally aren't super-specific on their context. So, I'd rather keep and move them as is.

If there's going to be a non-administrative Index and non-administrative Tasks at some point, then, well, yeah, that would be a good reason for renaming them. ;)

jenlampton’s picture

Status: Needs review » Reviewed & tested by the community

This is great, so much cleaner! :)

sun’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for reporting, reviewing, and testing! Committed to 7.x-3.x and 8.x-3.x.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

mstrelan’s picture

This is fantastic! It's so strange not having "Flush all caches" as the first thing under that icon though :(

itangalo’s picture

Great work. Removing my auto-download of the patch above. :-)

Status: Fixed » Closed (fixed)

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

cmstom’s picture

#2 worked great for me. My issue was that I had extra menu items in the top level that only occurred after upgrade from Drupal 6. I had these items in the top level admin menu: Status report, available updates, recent log messages, field list, recent hits, top access denied errors, top page not found errors, top referrers, top search phrases, views plugins, top pages, top visitors, help.

I obviously needed to clean up all these extra menu items that were cluttering up the space.

My function looks like this. I had to switch the quotes on top access denied and top page not found because there were quotes in the t() function.

  $admin_menu_exclusions = array(
    t('Status report'),
    t('Available updates'),
    t('Recent log messages'),
    t('Field list'),
    t('Recent hits'),
    t("Top 'access denied' errors"),
    t("Top 'page not found' errors"),
    t('Top referrers'),
    t('Top search phrases'),
    t('Views plugins'),
    t('Top pages'),
    t('Top visitors'),
    t('Help'),
  );

Thanks.

naught101’s picture

@thoughmas: You're probably better off just disabling and uninstalling admin_menu in D6, and then re-unstalling after the upgrade.

priya.chat’s picture

Issue summary: View changes

Thanks #2 jason.fisher, your solution worked for me .

bohus ulrych’s picture

Thanks #2 @jason.fisher
I wanted to hide these menu items to my users.
I made just one small modification to avoid warning messages in watchdog

if (is_array($menu_tree) && array_key_exists('#title', $menu_tree) && in_array($menu_tree['#title'], $admin_menu_exclusions)) {