same menu item titles = duplicate id values in markup = invalid markup
| Project: | YUI Menu |
| Version: | 5.x-2.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | drupalhizmetleri |
| Status: | closed |
Jump to:
At present, generation of id values from menu titles in line 236 of yuimenu.module is as follows:
$output .= '<div id="'. rep_char($menu['visible'][$mid]['title']).'" class="yuimenu">This can result in duplicate id values in markup and subsequent validation failure if there are menu items in different sections of the menu which have the same title (which Drupal does allow).
I would make a reccomendation but the only thing that comes to mind is some check and subsequent handling of this (i.e. testing for and appending "-a", "-b", etc in event of duplicate values) and that seems rough around the edges. I also don't need individual id values for each menu item in the project I'm currently working on, so it was easier to strip out the id generating bit altogether; obviously, though, this isn't a real fix. ...

#1
Same issue here, but it gets worse. If the title contains special characters, an ampersand for example, then they will end up in the ID, and the ID will be invalid (and as a result the whole page will fail validation).
Instead of using menu titles for IDs why not use the menu id, the $mid variable. This should be prefixed with something like "yui_menu_".
#2
Forgot to mention that this still happens in 2.3, where str_replace was added around rep_char.
#3
Thanks. Next version will create id with $mid variable and will loke like id="yui_menu_id_67".
#4
is it possible to test the version yuimenu 5.x-2.x-dev ?
#5
#6
Looks good to me.
#7
Automatically closed -- issue fixed for two weeks with no activity.