Drupal: dealing with nested children that share their parent's path

Let's say that you'd like to create a nested menu in which one of the children links to the same path as its parent. Something like:  people/friends people/friends people/family people/neighbors This works in theory-- the menu items will take you to the correct page. But if you're relying on Drupal to correctly set the active trail and expand the correct sub menus, you'll have to use a bit of a workaround. You're basically going to create dummy nodes that will redirect to the desired page rather than creating two menu links that have the exact same path. The parent (in menu) will redirect to the child's node. Method 1 (D6 only): Download and install CCK Redirection Create a Content Type 'Redirect Node' and add a CCK Redirection field to the content type Create a page node (node 1) with URL "people/friends" and add a menu link Create a 'Redirect Node' (node 2) and create a menu link for this new node. Set CCK Redirection field to the URL node 1 (people/friends). Set node 2's menu item to be the parent of node 1's   Method 2 (D6&7): If you want to get really fancy, you can take a more user friendly approach by combining CCK's Node Reference module with the Rules module. Download and install the Rules module (and Rules UI) and enable CCK's Node Reference module Create a Content Type 'Redirect Node' and add a Node Reference field 'field_redirect_target'. Be sure to configure this so that it is required, and users cannot select nodes of type 'Redirect Node' Add a new rule via the Rules module when content is going to be viewed if content is of type 'Redirect Node' Redirect to page: [node:field_redirect_target-path] Create node 1 of type page Create node 2 of type 'Redirect Node' Set Node Reference field to Node 1 Set node 2's menu item to be the parent of node 1's This method is a bit nicer for users, since it doesn't require them to find the system path for the target node.

Thanks for this, but I couldn't get it to work. I'm using D7, and I installed rules, node-reference, entity, etc., and I was able to get a selection of the redirect node to automatically go to the target, but that doesn't really seem to address the problem.

I'm looking for a nested menu, which seems so simple. I can get it to show in the menu hierarchy, but the sub-menus do not show up.

In case I'm not explaining this properly, I want something like this:

Main menu: address | about_us | subjects | map
| - science |
| - math |
| - english |

Where there are nodes for science math and english, but not necessarily a node for subjects ...

Is this really so difficult?

Any suggestions appreciated.

Thanks, Jim

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.