2
votes

I have a Drupal 6.22 site, with primary links like this (using Nice Menus):

Section 1
- Foo
- Bar
Section 2
- Page A
(...)

My client asked this: If a user clicks on "Section 1", the "Foo" page is shown. In other words, when clicking on any "Section" the user will be redirected to the first child of that section.

At first, I modified the menu item "Section 1" path to "section1/foo", but the breadcrumb in the Foo page (I'm using Menu Breadcrumbs) is showing:

Home > Section 1

I want the breadcrumb to show this:

Home > Section 1 > Foo

So that didn't work, so I installed the Redirect Module, defined a "section1 -> section1/foo" redirect, but I can't create menu items pointing to "section1" (it isn't an alias).

Any ideas? Thanks in advance.

2

2 Answers

2
votes

You need to edit the menu array directly. Open up template.php from the current theme you're using and add this inside the function themename_preprocess_page(&$vars):

print_r($vars['primary_links']);exit();

And then refresh any page on the site and you'll see a print out of the primary_links array. It looks something like this:

Array ( [menu-640 active-trail] => Array ( [attributes] => Array ( [title] => A Page Title ) [href] => node/20 [title] => A Page Link Title ) )

You can alter the [href] by setting it to your preferred value. You'll need to get creative with a foreach($vars['primary_links']) loop to get children and alter their parents appropriately, but it shouldn't be too difficult.

1
votes

This is a big pain in Drupal. My solution is to create a node specifically for the redirect page. (I actually create a content type called Redirect so I can have pathauto treat them differently... automatically create aliases like /redirect/page-name) After that node has been created, you can then set up a redirect from that page to the real page.

I also set up robots.txt to disallow redirect/* so that Google doesn't try to index the redirect pages if it does happen to find them.