开发者

Controllling Drupal's active/active-trail with duplicate menu items

I'm developing a site that requires some duplication of links within the menu:

Section A

-- Introduction

-- Testimonials

Section B

-- Introduction

-- Testimonials

Testimonials

-- Section A

-- Section B

So 'Section A > Testimonials' and 'Testimonials > Section A' point to the same node. But regardless of which menu link people use, I want the person to be in Section A.

The problem is that D6 doesn't like duplicate menu items, and it assigns the active and active-trail classes rather unpredictably.

So my thought was to create a placeholder node fo开发者_运维问答r each item in the Testimonials menu, and then set the URL to something like "testimonials/redirect/section-a", and then use mod_rewrite to redirect over to "section-a/testimonials".

With this solution, I will have no duplicate paths in the menu. I'm just hoping this doesn't somehow hurt my SEO.

Does anyone know a better solution?


I also have this problem. When multiple menu items link to the same content, Drupal will use the item with the lowest menu id as canonical - no matter which menu link you click, you'll get the active trail for the lowest menu id.

The best way I know to fix it, which I don't like, is to point your non-canonical menu items to a node that will redirect to the node you want (you could use the php input filter with a drupal_goto, or something similar)

Unfortunately, the path_redirect module will not solve this problem as the redirect paths it creates cannot be used as menu items.

I'm not sure why there aren't more people with this use case in d6 - it's pretty common in my experience to want top level menu items to point to the first child, and to want to set active trail to the first child.

nodesymlinks module solves the reverse use case - it allows you to set up multiple menu items, each with its own path, pointing to the same node. so, depending on which link you click in the menu, you get a different active trail. this module would be a good model for a "canonical menu item" module.


We had the same problem in our project and we managed to have the active trail working correctly setting in each duplicated menu item a "#n" at the end. For example:

Section A
-- Introduction -> node/1#1
-- Testimonials

Section B
-- Introduction -> node/1#2
-- Testimonials

Testimonials
-- Introduction -> node/1#n
-- Section B

is not the prettiest solution but definitely the faster one :) The only inconvenient we found is that if a user click first in "Section A -- Introduction" and right after in "Section B -- Introduction" the page will not be reloaded.

Hope this help


Multiple Node Menu might do the trick:

This module modifies the "Menu settings" in standard node editing form to allow managing multiple menu links to a node. The Drupal standard behavior is to only care about a single menu link for anode, all other menu links must be added through menu administration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜