I have so many active modules that the "Site Configuration" dropdown menu extends beyond the height of my screen. Recently, I went through and disabled a bunch of menu items under admin/settings/ that are basically "set once and forget" items. I figured it would be nice to hide them from admin_menu as well as from the navigation menu. Doing so was harder than I would have figured, though.

Anyhow, here is a patch against today's 6.x-1.x-dev version. Works for me; your mileage may vary.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Status: Needs review » Needs work

erm... and where are those items set to hidden?

pillarsdotnet’s picture

Status: Needs work » Closed (won't fix)

After applying the patch, they are hidden when I go to the admin/build/menu-customize/navigation page and uncheck the "Enabled" checkbox for those menu items that I don't want to see.

Tell ya what; I'm gonna mark this one "won't fix" because I stopped using the admin-menu (for performance reasons) and nobody else appears to be interested.

sun’s picture

Ok, but could you please elaborate on for performance reasons? Is there something special in 6.x I'm not yet aware of?

brei9000’s picture

Successful patch. Thank you!

stoptime’s picture

Yes, thanks!

hansrossel’s picture

Works nicely, thanks!

hansrossel’s picture

Status: Closed (won't fix) » Needs review

Setting back to needs review, could be good if this gets into the module. Admin menu is very handy but often it's interesting to hide certain menu items (like not to be used content types eg content profile, ...).

RikiB’s picture

Version: 6.x-1.x-dev » 6.x-3.x-dev
Status: Needs review » Active

Is there any hope in getting a patch for 3x?

sun’s picture

Status: Active » Closed (won't fix)

I don't think that this is the right approach. If you want to hide links, then you shouldn't grant access to them. In the case of content types, you can configure access permissions very granularly per role, for example. Same applies to everything else.

Links that have been customized to be hidden should already be excluded in 3.x.

PeteS’s picture

You can't think of any good reasons why an item would be placed in the menu, but disabled? Breadcrumbs. Pathauto. There are a million things that make use of the menu structure, where you don't actually want a menu item to show up in the actual menu.

I think the more important question is, can you think of a case where someone would intentionally disable a menu item, but still want it to show up in the administration menu?

Dmitriy.trt’s picture

I've made small patch to implement this. Be sure to clear site cache after disabling menu items. Patch was made from latest CVS code at the moment.

Dmitriy.trt’s picture

Status: Closed (won't fix) » Needs review

Status: Needs review » Needs work

The last submitted patch, admin_menu-6.x-3.x-hidden-items.patch, failed testing.

Dmitriy.trt’s picture

This is strange, I can't reproduce tests failure on clean local site with latest Drupal 6 from CVS, SimpleTest 6.x-2.10 and latest Administration menu from CVS. Described configuration with last patch passes all 48 tests. Am I doing something wrong?

jackalope’s picture

Status: Needs work » Needs review
jackalope’s picture

The patch in #11 works for me, and is much needed! Not sure what's going on with the tests, though.

Passer’s picture

Passer’s picture

Passer’s picture

I guess the main problem is that that the regular menu entires are copied and reorganized from admin menu.

Not the user-build menus preferences were used, but the modul given. So no hidden attributes are set in the database

crutch’s picture

Thank you #11

sun’s picture

+++ admin_menu.inc	5 Aug 2010 10:24:51 -0000
@@ -22,8 +22,8 @@
+    if ((isset($data['link']['type']) && $data['link']['type'] == MENU_CALLBACK) || $data['link']['hidden']) {

I didn't test, but I'm pretty sure that this also removes all local tasks from the menu.

Powered by Dreditor.

webster.’s picture

I was able to reproduce the issue that the original submitter had. I have tested the patch in comment #11 and it worked as expected.
Firefox-3.6.13
Drupal-6.20
Postgresql-8.4
Admin menu-6.x-3.0-alpha4

ashmiler’s picture

I have also used the patch in comment #11 and it has worked as expected. I am running Drupal 6.20 on Firefox 3.6.13
Postgres 8.4
Admin menu: Version 6.x-3.0-alpha4

pree93’s picture

I have also used the patch in comment number 11, admin_menu-6.x-3.x-hidden-items.patch, and I found that it did what I expected it to do.
I used the following:
Mozilla Firefox 2.6.13
Drupal 6.20
Postgresql 8.4
admin_menu-6.x-3.0-alpha4

serenecloud’s picture

I've been guiding some students through testing this patch. We used the latest 6.x-3.0-alpha4 rather than CVS on Drupal 6.20 (I had Postgres 8.1 running for it). Patch #11 worked well for us, I think it's also a possible workaround for the long menus bug: http://drupal.org/node/687750

chrisfromredfin’s picture

Status: Needs review » Reviewed & tested by the community

Interested in this ticket. I used OP's patch on 1.6 and it worked, and looked at the (rather simple) patch for 3.x-dev. Both seem good. Setting to reviewed & tested by the community to see if we can get a commit.

pillarsdotnet’s picture

Be sure to also apply the patch from http://drupal.org/node/511804#comment-3989706

sun’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Category: feature » task
Status: Reviewed & tested by the community » Needs review
FileSize
4.43 KB

Tested manually, custom links don't work (at all) for me in D6. But well, that's a horrible mess anyway.

Unfortunately, the same issue seems to exist in D7, too. Attached patch adds tests that prove the bug exists (in a rudimentary form).

pillarsdotnet’s picture

Re-uploading -- maybe the testbot has been fixed?

sugreen’s picture

This works for me:

module version: 7.x-3.0-rc1
file: admin_menu.inc
row: 369
added: || $data['link']['hidden'] == 1

if (!$data['link']['access'] || $data['link']['type'] == MENU_CALLBACK || $data['link']['hidden'] == 1) {

hidden may be 0,1,-1

pillarsdotnet’s picture

Status: Needs review » Needs work

Hmm.. I remember Randy Fay saying that the way to un-block such a request is to set the issue to "needs work" then back to "needs review".

pillarsdotnet’s picture

Status: Needs work » Needs review
FileSize
4.43 KB

And re-re-uploading...

drasgardian’s picture

The solution in #30 worked for me against latest 7.x-3.x-dev (although the line number for the change is now 381)

hanoii’s picture

Patch in #11 works just fine for D6 and I think it should really be included. @sun, as said on #24, this doesn't prevent local tasks from appearing on the admin menu.

jenlampton’s picture

Status: Needs review » Needs work

Patch no longer applies to dev brach :(

sun’s picture

+++ admin_menu.inc	30 Jan 2011 06:17:26 -0000
@@ -378,7 +378,7 @@ function admin_menu_links_menu($tree) {
-    if (in_array($data['link']['router_path'], array('admin/by-task', 'admin/by-module'))) {
+    if (in_array($data['link']['router_path'], array('admin/tasks', 'admin/index'))) {

This hunk is already part of #1097312: "Tasks" and "Index" links appear on the top-level and should be removed from this patch.

jenlampton’s picture

Status: Needs work » Needs review
FileSize
4 KB

okay, patch re-rolled for latest dev. Added the fix from #30 and removed the line as per #36.

YesCT’s picture

this will be super nice. for D6, should I retest #11, or wait to see if it gets committed for D7?

Status: Needs review » Needs work

The last submitted patch, remove_disabled_links_from_menu-282775-37.patch, failed testing.

aaron’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, remove_disabled_links_from_menu-282775-37.patch, failed testing.

pillarsdotnet’s picture

Status: Needs work » Needs review
FileSize
3.88 KB

Re-rolled.

Status: Needs review » Needs work

The last submitted patch, hide-disabled-menu-tiems-282775-42.patch, failed testing.

pillarsdotnet’s picture

Test needs to be rewritten, I suppose.

sun’s picture

Status: Needs work » Needs review
FileSize
4.98 KB

Thanks for re-rolling.

Attached patch fixes the code and tests. Took over some code from #742184: Shortcut.module integration.

sun’s picture

Category: task » bug
Status: Needs review » 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.

This fix will no be backported to 6.x-3.x.

Status: Fixed » Closed (fixed)

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

hixster’s picture

Status: Closed (fixed) » Active

Just installed 7.x-3.dev (March 9th 2012) today. I have disabled a bunch of menus in the structure section of navigation menu as I don't want authenticated users to see menus we don't want them to see.

I ran update, I have flushed all caches but the menu items still appear?

sun’s picture

Status: Active » Closed (fixed)

The expected behavior is backed up with automated tests, so something else must be wrong regarding #48.

Re-closing this issue.

hixster’s picture

Category: bug » support
Status: Closed (fixed) » Active

Sorry to re-open, but just need to double check this.
I made a clean install to eliminate module clashes.
I can hide the majority of disabled menu items, but can not hide disabled items which are children of admin/structure/menu - is this the expected behaviour?

pillarsdotnet’s picture

How many times must I un-follow this issue before it stops reappearing in my tracker?

sun’s picture

Category: support » bug
Status: Active » Closed (fixed)

@hixster: Please create a new issue for that. Thanks.