Reputation: 4056
I am developing a site with Drupal 7. I have styled the menu correctly and all this stuff. The problem is with the secondary menu.
My idea is to create the second menu immediatly behind the first menu, for example:
MENU_ITEM1 | MENU_ITEM2 | MENU_ITEM3 | MENU_ITEM4
MENU_ITEM1_SUBITEM1 | MENU_ITEM1_SUBITEM2 | MENU_ITEM1_SUBITEM3
And the structure goes like this:
1st problem, I cannot see secondary items 2nd Any suggestion on how to create this?
Thanks a lot!
Upvotes: 0
Views: 643
Reputation: 21
You can structure your menu with multiple levels within drupal, and select that menu (e.g. main menu) as the source for both your main links and secondary links, over at "/admin/structure/menu/settings".
Then you can implement drupal's theme_preprocess_page() function in your template.php file:
function themeName_preprocess_page(&$vars) {
if (isset($vars['main_menu'])) {
$vars['primary_links'] = theme('links__system_primary_menu', array(
'links' => $vars['main_menu'],
));
}
else {
$vars['primary_links'] = false;
}
if (isset($vars['secondary_menu'])) {
$vars['secondary_links'] = theme('links__system_secondary_menu', array(
'links' => $vars['secondary_menu'],
));
}
else {
$vars['primary_links'] = false;
}
}
Now all you need to do is echo/print the new variables ($primary_links
& $secondary_links
in this case) now available to page.tpl.php.
Upvotes: 1
Reputation: 5520
Not all drupal themes allow you to style your menus like this.
If you have a theme that supports nested menu structures, you just need to nest your menu items in the menu settings. Fortunately, drupal handles this relatively well thanks to the drag and drop interface, you just need to make sure that any of your top level menu items have the "expanded" box checked.
If you would like to see a quick example, you can just look at your "navigation" menu settings, they are already nested and expanded, so you'll know what your main menu settings should look like.
Upvotes: 0