I'm not sure if this is an actual bug or something by design.
In my custom theme, I'm using theme_nice_menu_primary_links like this in template.php:
$vars['primary_links_tree'] = theme('nice_menu_primary_links','left');
In page.tpl.php:
<?php if ($primary_links): ?>
<div id="primary-menu">
<?php print $primary_links_tree; ?>
</div> <!-- /primary-menu -->
<?php endif; ?>
I have another menu of which I'm trying to place into my theme in the same way, but of course using theme_nice_menu:
$menu-tools = theme('nice_menu',0,'menu-tools',0,'down');
$vars['menu_tools_tree'] = $menu-tools['content'];
In page.tpl.php
<?php if ($menu_tools_tree): ?>
<div id="tools-menu">
<?php print $menu_tools_tree; ?>
</div> <!-- /tools-menu -->
<?php endif; ?>
Some of you may notice right away that I'm calling this other menu in the same way theme_nice_menu_primary_links calls the primary links menu, by using a 0 as the $id, thereby bypassing the need to configure a block.
The pro of doing this is that I don't need (and Drupal doesn't need) to deal with blocks to render a menu. The con of doing this is that the HTML that's rendered assigns the same CSS id to this menu as what gets assigned to the primary links, a minor detail but still a source of confusion.
<div id="primary-menu">
<ul id="nice-menu-0" class="nice-menu nice-menu-down">
...
<div id="tools-menu">
<ul id="nice-menu-0" class="nice-menu nice-menu-down">
Not being familiar with the code, I don't understand why it would be necessary to deal with the blocks subsystem when working with raw menus. The project page for Nice Menus implies that using blocks is unnecessary: "For themers, it is also possible to theme a menu as a Nice Menu directly by using the provided theme functions so a block is not necessary." Yet for this issue with the CSS id, one would still need to configure a block that isn't used if one wanted the CSS id to be unique.
I don't know how much it is worth it to fix.
Comments
Comment #1
add1sun commentedThe multiple IDs not being valid HTML is addressed in another issue, #363366: Displaying same menu twice generates invalid HTML. Basically the NM ID is being used just for CSS so if you want to target a particular one you can. Perhaps instead of ID number it would make more sense to use the menu name instead. That way, you'd get classes (since we'll move this from being an ID to a class in the other issue) like this instead, which is probably more useful all around:
I won't make a change like this to the 1.x version, but since 2.x is all about changing things and people will most likely need to edit things for the upgrade anyway, I'm not opposed to changing this there. Thoughts?
Comment #2
Sborsody commentedI've noticed that other modules utilize "class" in place of "id" and I don't think there are many other viable alternatives that are as simple to implement. It gives themers a lot more flexibility in writing the overall template while at the same time providing a unique way for them to reference automatically generated HTML code.
Comment #3
add1sun commentedHm, since the class/ID issue has been fixed up now, I'm going to won't fix this one.
Comment #4
klonos...at first I didn't like the idea of 'won'tfixing' this, but after giving it a bit of extra thought I realized that going with the ID# is much better/safer. The most important reason I can think for that is because there might be multilingual menus and their names might contain non-latin characters. Not that good an idea using such characters in css files.