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.
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.