When editing a node, the menu item of the node is not generally visible. This patch is a way of keeping the menu trail for viewing the node expanded also while editing it.
Example:
- I have a node with (internal) path node/123 and a menu item that is NOT at the root level. For instance there may be a root menu item "Animals" with a submenu item "Cat" that leads to node/123.
- At node/123 I see the menu "Animals" expanded and "Cat" marked as active.
- When I click to edit the node, I come to node/123/edit where the "Animals" menu is collapsed and the "Cat" menu not visible. The breadcrumb trail still works (shows Home › Animals › Cat) but not the menus.
Desired behavior:
Keep the Animals -> Cat menu expanded also on node/123/edit, but do not highlight "Cat" as active (because the exact path doesn't match node/123).
Maybe this is a feature request, because I hardly find anyone else reporting it as an usability issue (#890784 and #307733 were the most similar I found). But since i found a "TODO" in menu_tree_page_data that was related to this, it seems someone once thought it needed a fix. I use Drupal 6.20 with a Zen-subtheme.
Solution?
The attached patch solves the issue for node/%/edit, node/%/revisions, node/%/children and any such "local tasks" (tabs) where the wildcard-parent node/% does NOT have a menu entry (there are instead menu entries for each individual node/1, node/2, ...).
The case where the wildcard-parent has a menu entry (like admin/build/menu/item/%/edit) works both before and after the patch. There is no restriction to just work on node/... paths, if the same situation arises elsewhere it is probably also fixed.
The algorithm is simply to strip the last argument ("/edit", "/revisions", ...) from $_GET['q'] to find the path to the node, and then search for a menu entry for it. If you would need to strip two levels or more to find a menu entry it still fails (shows no menu expanded).
| Comment | File | Size | Author |
|---|---|---|---|
| menu_node_local_tasks.patch | 1.71 KB | emok |
Comments