Recent comments

A common menu use case that Drupal 6 has trouble supporting (or very possibly I'm ignorant)

firebus's picture

Here's a menu navigation use case that I run into all the time:

"A click on a top level item in a menu should redirect to it's first child."

For example, if this is Primary Links:

About
-Overview
-History
-Contact
Products
-Beef
-Chicken
-Statuary

Then if I click on About I should be taken to the Overview page.

This is possible in Drupal 6 - you can create two menu links that point to the same node. If you create one of the menu links via the node edit form, D6 will even remember which one it is (Drupal 5 would get confused).

What's difficult is specifying which menu item should have the active trail once you make it to the Overview page. Usually you want the child "Overview" menu item to be active, and not the parent "About" menu item. However, there's no way to specify this in D6 - Drupal will set the menu item with the lowest id number to be the active trail.

You can't work around this problem with URL Aliases. Drupal is too smart for you, it seems to dereference the multiple aliases, and behavior is the same.

I was trying to solve the problem for the tenth time two weeks ago, when I discovered the path_redirect module - which almost does the right thing! You can create new paths - not aliases - that redirect to the same node. Unfortunately you cannot add path_redirects to the menu system.

There's an open issue requesting menu functionality and as of May 11th there's a work around by sbandyopadhyay that allows you to put path_redirects into the menu system.

However, the maintainers of path_redirect are skeptical that this feature should be added. I think that, for the use case described here, they are probably right. It would be better to have a simpler UI. Maybe something similar to - or an extension to - nodesymlinks that would let you create multiple menu links for a path and specify which is "canonical".


Comments

CCK redirect

I found a solution that works pretty well (at least for me).
http://drupal.org/project/cck_redirection

This module lets you create a CCK filed that when the node is viewed will redirect the user to whatever its field value is. SO what I do is a create a content type and name if "redirection" or whatever comes to my mind at the time, no one but admins will see it any way.

This way you can the path to the node anywhere on your menus and user will never know he/she went to a different node for a second.

Sweet!


firebus's picture

i've done that too!

or something similar (wrote a small helper module to redirect based on the contents of a CCK field)

it works, but it's a little kludgey


Rules?

Can't you use Rules to redirect from About to Overview, whenever About is selected? And wouldn't this arrangement give your breadcrumb the list you normally want?


firebus's picture

rules

that sounds like a fragile fix.

if someone wants to modify the menu through the UI they will also have to change the rules - which might be difficult for the average drupal admin.

an equally bad workaround i've used in the past is to create a "redirect" content type, that takes a link field and executes a drupal_goto on view.


http://drupal.org/project/men

firebus's picture

my ignorance FTW

thank you! i'll check it out


Try the menu firstchild

Solution?

Interestingly, this showed up on Planet Drupal only two articles after another article on similar problems, but for D7. There, the Menu Trails module ( http://drupal.org/project/menutrails ) was mentioned. Wouldn't that solve your problems?


firebus's picture

i don't *think* so...

it looks like menu trails allows you to set the active trail for items that are not in the menu navigation system.

in this use case, i have an item that is in the menu navigation system twice, and i want to control which menu trail is active when i'm viewing the item.

i'm not sure what would happen if you tried to apply menutrails to an item that exists in the menu navigation system - maybe it would work!


Powered by Drupal - Design by Artinet - Amazon Affiliate