Admin menu doesn't update when new menu items are added either manually and programatically (on FF3/WinXp, themes: Garland and Pixture).

I tried emptying all cache* tables and browser cache.

Thanks,

Vianney Stroebel
Co-org.net - Développement Drupal - Paris.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Viybel’s picture

UPDATE:

It does update when a menu item is added by a module, but not when it is created by a user (through the node edit form or the menu administration form).

Vianney Stroebel
Co-org.net - Développement Drupal - Paris.

sun’s picture

Title: AM doesn't update when menu items are added » Manually created menu links are not displayed
Component: User interface » Code

Better title.

jbrauer’s picture

Perhaps related but I have also noted that if I move a menu created by a module (move in the menu that is) it doesn't move in admin_menu. For example Organic Groups administration adds a new item and sub-items under the "Administration" menu but trying to move those under the "Site Building" menu doesn't result in any change in admin_menu.

pwolanin’s picture

Category: bug » feature
Priority: Critical » Normal

Right now the admin menu is built based on the router, and hence it is not expected that it would reflect changes you make to the navigation menu.

If you want to be able to re-arrange links within admin menu, I might suggest that we tweak it so that you can use the menu module interface to make the changes. In that case you'd have to make the changes separately in both places - but that might be better since you could customize the admin menu without forcing the /admin page to match.

sun’s picture

Version: 6.x-1.0 » 6.x-1.x-dev

Since moving, removing, and creating of links in admin menu was possible before, your proposed plan to allow users to alter admin menu's links separately definitely sounds sane.

Zach Harkey’s picture

I agree with pwolanin's suggestion. It would be extremely useful to be able to manually add shortcuts to frequently used administrative views, etc.

@sun When you say "creating of links in admin menu was possible before", do you mean this was possible in the 5.x version?

psynaptic’s picture

I've been using simplemenu for about a year now and have come to depend on the ability to use any Drupal menu in the simplemenu. I heard that this module would be merged with simplemenu at some point but that seems to have been sidelined.

Is there a reason that this module can't be modified to allow use of custom menus?

sun’s picture

@Zach Harkey: Yes, I meant the 5.x version of DAM.

@psynaptic: The idea of a generic menu rendering module was not completely abandoned, but DAM serves a very specific purpose and does some very tricky magic to achieve the administrative menu. I appreciate that so many users like the behavior and style of DAM. However, if all you want is a customizable version of DAM for arbitrary menus, then I would suggest to enhance Dynamic Rendering module with a "Dropdown menu" plugin, so it allows to customize and load the CSS + JS for a menu like DAM and attach it to a certain CSS selector on the page.

Please note that this issue is about adding/editing/removing custom links in the administration menu only. Thanks in advance for staying on focus by not commenting on off-topic issues.

Zach Harkey’s picture

FileSize
63.13 KB

@psynaptic, I've resorted to using both. (See screenshot attached)

Pretty kludgy, but I'm getting by this way.

markfoodyburton’s picture

Subscribing

sun’s picture

Maybe a starting point: Someone managed to hide disabled menu items in #282775: Hide disabled menu items

kvarnelis’s picture

I'm puzzled too.

I have "create story" created as the first entry in my administration menu.
It shows up as the first entry after "administer" in my admin-by-task page and in my navigation menu.
It does not show up in admin menu.
I have tried wipe and rebuild.

cbrantley’s picture

I would also like this funtionality. Since the 5.x version worked this way, it's a shame that the 6.x version does not. It means that upgrading my site from 5.x to 6.x jsut got a lot more difficult.

headkit’s picture

subscribing and very interested in the feature

rob_connolly’s picture

subscribing, very interested in this!

jaskho’s picture

I'm considering taking a stab at making a patch for this, but I'm not sure where to get started in terms of coordinating efforts. Should I just dive right in then report back when I have something? Is there anyone I should consult with in terms of avoiding known gotchas and bits of complexity I may be unaware of?
Thanks

sun’s picture

This feature requires expert skills in Drupal's menu system. The effort is coordinated in this issue. Reporting also happens here. Me (and probably pwolanin) are happy to answer questions.

jaskho’s picture

@Sun: On the surface this looks like a trivial matter of grabbing any links under 'Navigation' that target /admin/* and merging them into the admin_menu output.

What am I missing that requires expert menu system knowledge?

And, if answering that question would be a waste of time -- if what really needs to happen is for me to go become a menu system expert, then check back -- please say so. I REALLY don't want to waste your time here with 'help' that just makes more work for you.

Thanks

sun’s picture

Yes, that's it basically. However, if I'm not mistaken, the problem is the _merging_ in that summary.

We not only want custom links, but also other router items that have been moved around to show up where they have been placed. This is the first step.

The second step is to ensure that we don't get duplicate items in admin menu when one of the items is moved somewhere else (again).

FYI: The responsible code lives almost solely in _admin_menu_rebuild_links(), admin_menu.inc.

jaskho’s picture

OK, thanks. I'll see what I can come up with.

liquidcms’s picture

just to add to this (and subscribing).

i was reasonably sure that i could move items that were "poorly placed" by modules such as Rules and Panels that didn't put their menu items under Site Building where they should have. I moved them in menu system and they then DID show up in correct place in Admin Menu. But, i just did a wipe/rebuild and now they are back (to modules wrong place) - even though they are still in the correct place in the nav menu (and i can no longer get them back where i want them).

plus, i have a views created path that shows up as its own top level item in admin menu even though not there in nav menu.

very confusing

i know in a Drupal 5 system Admin Menu matches what we set up manually in Nav Menu - but i guess we've lost that feature in Dr6 version :(

Dain Berrett’s picture

Just wanted to add my voice: I first noticed this issue when I enabled the Advanced Help Module. The following links show up now as top level links in my admin menu: Advanced Help, Example Help, and Help. I tried to rearrange in 'Navigation' menu but the rearrangement is ignored (which makes sense now from reading this thread). Anyways, only posting the strange fact that the 'Advanced Help' writes to include those links in the top level navigation of admin menu, but there is no way to disable it.

Besides a rewrite of the module to enable a 'rearrange' UI, in the meantime is there something I can do programatically to exclude these three links from Admin Menu, without disabling the modules?

sun’s picture

Title: Manually created menu links are not displayed » Allow to alter/customize/add links in administration menu
Version: 6.x-1.x-dev » 6.x-3.x-dev

Better title. New features go into 3.x only.

jwarner’s picture

Subscribing

sun’s picture

In the meantime, I'm tinkering intensively about reverting the admin-menu-in-a-separate-menu logic and behavior of admin_menu in 6.x and replace it with substitute functions for Drupal core, which allow us to perform alterations on the (re)built menu tree. Exactly this copying of the entire menu structure below admin/* 1) makes this issue impossible 2) led to a long list of caching issues regarding outdated menu items in admin_menu 3) required to introduce a "wipe & rebuild" button that no one really understands.
It is also the reason why admin_menu 2.x has no chance to get into Drupal core. The goal for 3.x is to make it core-worthy as-is.

jbc’s picture

Subscribing. Ditto the comments about Advanced Help. V. inconvenient. Also I like to trim unnecessary words out of various menus (Building rather than Site builidng; Content, rather than content management etc.), making menus more compact. Can't do since migrating to D6x

ha5bro’s picture

Subscribing. Admin menu makes drupal sites so much more usable, but we need the ability to add custom menu items. Ashame that it didn't make it through to the d6 module, hope this can be fixed.

In the meantime, does anyone have a way to manually refresh the menu?

emilymoi’s picture

subscribing

chales’s picture

This is something I just ran across. The weird thing is it's in a multi-site config only one site is showing the top level Advanced help links. The other sites are showing it as Administer >> Advanced Help and Administer >> Example Help

This happened after trying to adjust some menu items to move some help files under "Help". I've disabled and run uninstall on admin_menu but it still holds them in the same places.

najibx’s picture

glad I found this thread and knows something is missing and under development.
subscribing.

BeatnikDude’s picture

subscribing

elly’s picture

i hate 'subscribing' but i want this feature so bad that i'm doing it anyway. :)

marcvangend’s picture

Fortunately, I know how to write a quick hook_menu to get what I need, but lots of users don't. This is a very needed feature!

For who's interested, this is the workaround code I use to create a shortcut to editing a certain node (nid 19):

/**
* Implementation of hook_menu().
*/
function mymodule_menu() {

  $items['admin/content/node/myspecialnode'] = array(
    'title' => 'Edit my special node',
    'page callback' => 'drupal_goto',
    'page arguments' => array('node/19/edit'),
    'access arguments' => array('administer content'),
    'weight' => 1,
    'type' => MENU_LOCAL_TASK,
  );

  return $items;
}

This effectively creates a menu item called 'Edit my special node' under 'Content' in the admin menu, which redirects to node/19/edit.

fallsemo’s picture

Subscribing.

vertazzar’s picture

Subscribing.

reubenavery’s picture

Subscribing...

luxx’s picture

Will try it using hooks, but this feature would be greatly appreciated. Subscribing.

Poieo’s picture

Subscribing

TravisCarden’s picture

Subscribing

slosa’s picture

subscribing

kevinquillen’s picture

So, to be clear, admin_menu does not currently facilitate creating a menu item from Menu Admin and having it show in the drop down(s) of admin menu?

PeteS’s picture

Forgive me if this discussion has probably already taken place, but is there a particular reason why admin_menu can't just use something like menu_tree_all_data()?

It just seems like the module is going to a ton of trouble to determine a menu structure that for most sites would simply be a rendering of the navigation menu, e.g. like what menu_block does, but with the additional features that admin_menu brings to the table. What is the need to call menu_router_rebuild() (which, IMO, seems like way too internal of a function to be calling at this level) and basically manually dig out these menu items from the menu_router table, when Drupal has already abstracted all of that work with the menu API?

reubenavery’s picture

@PeteS: That's exactly what I was wondering. After digging in the code on this, I was scratching my head as to why it was so complicated like this. Seems overengineered and sort of misunderstanding the new design goals of the D6 menu system.

Not trying to troll here... promise

sun’s picture

Category: feature » task
Priority: Normal » Critical

In case you don't know: admin_menu's current implementation was written by one of the fine folks who designed the D6 menu system.

I have good news though: I am rewriting the implementation currently. To turn into reality what UX people envision for D7.

That will solve this and a few other issues in the queue.

sun’s picture

Assigned: Unassigned » sun
Status: Active » Needs work
FileSize
7.87 KB

Complete rewrite initialized.

First pass. D7. Works better than I imagined.

sun’s picture

FileSize
14.91 KB

Second pass. Bringing back baseline of menu additions.

sun’s picture

FileSize
24.34 KB

Third pass. Menu additions are fully functional back now. Using drupal_render()-style.

sun’s picture

Status: Needs work » Patch (to be ported)
FileSize
32.4 KB

Final pass. Committed to HEAD (D7). Testers welcome.

marcvangend’s picture

Wow, feeling productive tonight? Thanks, I hope to test it this weekend.

MGParisi’s picture

sun’s picture

Status: Patch (to be ported) » Needs review
FileSize
35.56 KB

Committed attached patch to 6.x. Please make sure you backup your database before upgrading.

I could use some help to make the upgrade path a bit more friendly. I've not yet completely understood how and when the menu system thinks that an existing router item can be updated with new values from hook_menu() resp. hook_menu_alter(), and that is the critical part here. We have to reset all administrative items, so their menu links are properly updated. I've already tried to reset the 'customized' column only, but that was not sufficient.

MGParisi’s picture

sun, if you are handling the #446794: Administration Menu is Broken on Upgrade! issue here, then can we close out the other item?

kevinquillen’s picture

Why specifically does admin_menu have to run menu router rebuild functions? On very large sites this can be a performance killer. Post #42 has a good question.

sun’s picture

@gh0st25: That is history. admin_menu uses hook_menu_alter() now. However, to upgrade from a previous version, we have to make sure that all items below admin/* end up in the administration menu.

kevinquillen’s picture

Okay, still using 3x dev atm

markus_petrux’s picture

I had a custom module that was implementing hook_admin_menu() to append a new submenu, for backend operations. Now, that extesion is broken.

a) Should I use hook_menu_alter() and make sure my custom extension is executed after admin_menu implementation of hook_menu_alter()? ...or....

b) Could you please add something like drupal_alter('admin_menu', $items) from inside admin_menu_menu_alter(), just after admin_menu is done adding/changing menu items, before hook_admin_menu('flush_caches') ?

With b) my module does not need to alter its module weight, which seems something more robust, but it would add another hook that's not really necessary. So should I go for a) ? Would that be ok for future changes in admin_menu?

markus_petrux’s picture

In regards to my previous comment... never mind, I got what I needed implementing hook_admin_menu_output_alter(). :)

sun’s picture

Note that I'm not yet very happy with the new implementation. In an ideal world, all elements in the structured $content array should only return LIs (and everything below as usual), so #prefix and #suffix will add the wrapping UL.

Additionally, elements in $content do not seem to be sorted properly.

markus_petrux’s picture

hmm... we need to insert a submenu on the admin menu bar with links to paths that do not start with "admin". This is for backend operations. The items are taken from a custom menu (menu_name = 'backend') which is built by a custom module, that's also visible as a menu block for certain users. Some users may not have access to the admin menu.

Since we may have more than one menu item with the same path on different menus (backend and admin_menu), we cannot use hook_menu(), hook_menu_alter() to insert links to the admin menu. So I think admin menu should provide a hook that allows to insert menu items dynamically. Now, it is possible using hook_admin_menu_output_alter(), where I can even control the position of the submenu with the '#weight' attribute of the top level menu item inserted to the admin menu.

Our implementation is now ok, but if you change the admin menu api, then please consider this use case where we need to dynamically add items to the admin menu that also exist in another custom menu, and where paths do not start with 'admin/*'.

sun’s picture

I wonder whether I should open a separate issue for (perhaps) introducing a new #theme function that allows to render partial menu structures and other stuff, or other ideas/solutions. Actually, the topic of this issue is solved already.

WildKitten’s picture

HI Markus,

I tried to find something about hook_admin_menu_output_alter(), but your posts is the only place where I saw it. In drupal 5 I could add my menu with function mymodule_admin_menu(&$admin_menu, $may_cache) , but I can't find replacement in drupal 6.
Can you give me more data about hook_admin_menu_output_alter(), or point me in right direction? Thank you.

markus_petrux’s picture

@sun at #60: I'm fine with another issue as long as a method to alter the admin menu structure remains in one form or another.

@oboskovic: In admin_menu 6.x-3.x, look at admin_menu_output(). You'll see a line like this:

drupal_alter('admin_menu_output', $content);

In your module, just create a function like:

function mymodule_admin_menu_output_alter(&$content) {
  // You can alter the admin menu output here.
  // $content['menu'] contains the HTML representation of the items
  // admin menu builds with menu_name = 'admin_menu'.
  // See admin_menu_menu_alter().
  // $content['links'] contains the top level items of the admin menu.
  // You can add more items here and play with the #weight attribute to
  // place them where you need.
  // For information on how to build your items, look at the inline docs for
  // theme_admin_menu_links().
  // Use something like var_dump() to figure out the structure, or look at
  // admin_menu_adjust_items() for examples.
}
sun’s picture

FileSize
1.94 KB

Yay! Thanks! I've turned that into an "official" admin_menu.api.php! :)

sun’s picture

FileSize
3.67 KB

This is what I have on my hard-drive currently... It feels a bit dirty, so I'm asking for feedback/review.

Basically:

- We statically output UL tags.
- The menu tree and menu links rendering functions use an additional $depth parameter to (internally) control whether to output ULs (for sub-item-lists) or not (for top-level list items).

Having to do this in two different locations makes it extra shitty. I already tinkered about whether it would make sense to entirely alter admin_menu_tree_output() to produce a drupal_render()able array that is suitable for theme_admin_menu_links() ? That would likely have the additional benefit that hook_admin_menu_output_alter() implementations would be able to alter the entire menu tree... though it might also be a bit heavy regarding processing time (but it is cached on server-side and client-side anyway).

markus_petrux’s picture

Producing a drupal_render()able array would make it more complex to alter, I think. Aside from the need to first build that array and then the rendering passes (more cpu and memory).

If we want to alter the tree, we can already do it.

If we want to alter the *look* (adding/changing CSS classes), then maybe using a single theme() function to render items in the admin menu would allow sites to override that. There are now 2 different methods used to render the admin menu, maybe admin_menu_tree_output() can be written in a way that when processing individual items, the data structure for each one can be the same as the data used in theme_admin_menu_links(), and then both methods could use the same theme() function to render individual items. ¿?

sun’s picture

FileSize
9.6 KB

ok, I forked the Toolbar of core tonight. See #402058: Requirements for Administration menu in Drupal core for a screenshot. The new module, currently consisting of a new style and a new (not completed) widget, applies the look of that core "toolbar" to admin menu.

Working on that clarified a lot of things.

We most probably want to do what I already mentioned in my previous comment, because

1) admin menu widgets may also want to alter/add to the menu.
2) at least all top level items in the menu need a special CSS class, in admin_menu_toolbar's case to apply a certain styling to those top-level items only. (job of this module though, but currently it has no way to do so)

You can find the code for admin_menu_toolbar in latest HEAD, compatible to D7, of course.

Attached is the corresponding patch for admin menu itself, advancing on the previous one (but still not containing aforementioned change in menu rendering).

Overall, we have to go a bit away from thinking admin menu == menu only. I envision 3.x to be a dumping ground for various administrative widgets. The basic widgets are: a) The icon menu, b) the admin_menu/management menu, c) the user/actions menu. Stuff like Devel's switch user list should be considered as extension/widget.

sun’s picture

tha_sun    seen markus_petrux*
Druplicon  markus_petrux was last seen in #drupal-dev 25 weeks 2 days ago saying 'seen d_rewish?'.

Markus, I'd really love to chat with you! :)

markus_petrux’s picture

lol... I think I have an IRC client here, yes. I'll see if I can connect in an hour or so.

Please, just be patient, as I don't write in IRC quickly. :(

markus_petrux’s picture

Ok, so admin menu != menu only, but we have 2 different sources of items here, and there needs to be a place where it is possible to treat stuff coming from the Drupal administration menu as if it was admin_menu food.

Maybe you could transform the output of menu_tree_all_data('admin_menu') into an array similar to the one used in $content['links']. That way it would be possible to use the same rendering method for both, $content['links'] and $content['menu'].

And you don't need admin_menu_tree_output(), as it all will be rendered using theme('admin_menu_links'). And theme('...') is something that can be overridden.

Then, maybe hook_admin_menu_output() could be renamed to hook_admin_menu_content_alter(), or hook_admin_menu_tree_alter().

widgets on the server side could be implemented using this hook_admin_menu_xxx_alter(), and we already have Drupal.admin.behaviors if widgets want to do stuff client-side. All they need is a selector, and then they can alter the DOM in any way they need.

Not sure if this helps. :-/

markus_petrux’s picture

More... the stuff that comes from Drupal administration menu could be turned into admin_menu widgets. One of these for each top level item, and then we may not need $content['links'] and $content['menu']. All could be placed in $content['links'], and that would make it even easier to manage, I think.

For example, there could be an admin_menu settings screen where all top level items can be re-ordered, enabled, disabled, create custom widgets, etc.

sun’s picture

Status: Needs review » Fixed

FWIW, I've committed that last patch to 7.x-3.x and 6.x-3.x.

Let's continue the remaining discussion in #527908: Rework structure and rendering of menu and additions/widgets. Thanks!

Status: Fixed » Closed (fixed)

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

amclin’s picture

The latest alpha 6.x-3.0-alpha4 still doesn't include the functionality to add user-generated items (like custom views or pages that have menu entries) to the administrator menu.

halloffame’s picture

Subscribe

John Carbone’s picture

You can add a View to Admin Menu by setting the path on the page display under "page settings" for the View to admin/content/whatever-you-want and adding a "Normal menu entry" of whatever you want to call it. Admin menu will pick it up. But... if you try to add the same link through admin/build/menu it won't work. Cost me an hour to figure that one out... Might as well share it. lol.

MyriamB’s picture

This #75 solution worked for me. I was trying with only the path setting with my view, but then with a "normal menu entry" inside my views settings, under navigation menu, I finally got it in the so practical Admin Menu. Thanks

interestingaftermath’s picture

The solution is #75 works just what about adding to that item to make a drop down menu? I have 3 views that are for Management. I'd like to add a Manage item to the Admin Menu and then have the 3 views listed below it. Any ideas?

maomaohuhu’s picture

horrible solution to #77. Create an extra view that will serve as a Title item for the dropdown.

EDIT:
- create a view that will serve as Title Item in the admin menu ( make it a dashboard view ). In the view UI, chose "normal menu entry" and give it this path : "admin/myNewSection" . You can adjust the weight here.
- For the views that need to go in the dropdown , from the Views UI, chose "normal menu entry" and give it this path : "admin/myNewSection/mypage"

That should do it for the top admin menu.

Now, in the menu administration page, the items won't be where you expect. Think of that administration page as affecting only the left navigation menu and fix it as you please.

Of course, this is only necessary for D6 without the patch / prior to 6.x.3 .

AlonGoldberg’s picture

Thank you markus_petrux at response #62 .
You are my hero.
:)

renenee’s picture

Thank you. Thank you. #75 worked for me to get a views page into the administration menu.

SchwebDesign’s picture

subscribing. Is this really fixed? doesn't seem there's still a way to manually add a menu item (and subitems) without a big work-around like http://drupal.org/node/276751#comment-4103990

msamavi’s picture

Thanks John Carbone, it worked for me too.

virtuali1151’s picture

Status: Closed (fixed) » Active

Has anybody been able to get this to work with a views feed by chance..?? I cant seem to get a feed to get added to the admin menu....

sun’s picture

Category: task » support
Priority: Critical » Normal
Status: Active » Closed (fixed)

Adding and customizing links is known to not work correctly in the D6 versions.

Upgrade to D7.

druvision’s picture

Here is how to add items: http://blog.urbaninsight.com/comment/1400

It also works with Drupal 7.x

mandclu’s picture

Issue summary: View changes

The link posted by druvision takes me to a 404 :(