Nice Primary Menus provides dynamic primary and secondary links.

Overview

Primary links are the links that appear at the top of Drupal.org, including (currently) "Documentation", "Download", "Support", "Forum", "Contribute", and "Contact".

Nice Primary Menus extends the Primary Menus module so that a second level of links (Secondary Links) appears below the Primary Links. These secondary links appear when the mouse hovers over one of the Primary Links. For example, using Drupal.org as an example, hovering over "Download" could bring up another row of links underneath the primary links. These links might include different versions of Drupal ("5.1", "5.2", "5.3", "5.x", etc). The user could then click on a link (e.g. "5.x") to go to the appropriate page.

Note that the secondary links do not have to appear below the primary links. They can also appear to the left or the right.

Prerequisites

Install Nice Menus, a prerequisite for Nice Primary Menus.

Modifying your theme

To use this module, you must modify your theme.

Replace the theme('menu_links', $primary_links) with theme('nice_menu_links', $primary_links),

OR

If you've already overridden theme_menu_links, add the <li id=...> as is done in

theme_nice_menu_links, i.e.:
  $menu = menu_get_menu();
  foreach ($links as $index => $link) {
    $output .= '<li id="menu-link-'. $menu['path index'][$link['href']] .'" ';

and then call theme('nice_primary_menus');

Zen Theme

Note that for me (using the Zen theme), I opened my page.tpl.php template file and changed

<?php print theme('links', $primary_links); ?>
to
<?php print theme('nice_menu_primary_links'); ?>

Bug Fixing

Open up nice_primary_menus.module. In the function named nice_primary_menus_form_submit(), the update is always executed, never the insert (else clause). Changing the if clause to "if (isset($delta) && $delta!=NULL) {" causes the insert to be executed. However, even so, it is only called when modifying an existing menu item. This function does not work correctly for new menu items since they don't have a mid yet ($form['mid']).

So, before installing the module, change the if clause in nice_primary_menus_form_submit() to read "if (isset($delta) && $delta!=NULL) {"

Installation

Enable the module and head over to Adminster->Site Configuration->Nice Primary Menus. Configure these options as desired; leave the defaults if they look fine. (They were fine for me) Now, access the menus at Administer->Site Building->Menus. Add menu items to the Primary Links menu. The root items (those that are immediate children of "Primary Links") are those that will be Primary Links. The items that are children of these root items are the Secondary Links. In other words, using Drupal.org as an example, "Download" would be a primary link. Secondary links would be listed as immediate children of the "Download" menu item.

Note that since we're putting our Primary and Secondary links into the same menu hierarchy under "Primary Links", you don't need to select anything under the "Nice Secondary Menu" on the menu add/edit page.

Also, given the buggy code described above, menu items aren't configured appropriately when they are created. For them to work with nice_primary_links, you must create the items and then edit the item. Only then will it be correctly configured (e.g. have an entry in the nice_primary_menu table).

So, create a menu item under Primary Links. THEN, go back and edit the existing menu item, submitting it again, even if you have made no changes. Only when you select submit on this existing item will the insert be executed appropriately. Now, add secondary menu items below this primary menu item.

Theming

Just like Nice Menus, Nice Primary Menus can be themed nicely. Check out the documentation for Nice Menus to see how it is done.

Enjoy, and thanks to douggreen for such a 'nice' module! ;)

Notes

  • If you get a foreach error upon installation, make sure you have some primary links defined. Once you define some primary links, the error should go away. (The error would be something like this: "warning: Invalid argument supplied for foreach() in /home/newmill/public_html/sites/all/modules/nice_primary_menus/nice_primary_menus.module on line 62.")
  • If you've followed these steps but it's just not working, make sure that you've got the appropriate entries in the nice_primary_menus table. There should be a row for every one of your primary links. The 'mid' column corresponds to the menu id of your primary links. If the correct database entries are not in place, you could mess with the code in nice_primary_menus_form_submit() to get them to add correctly, or you could just add the correct database entries manually.