Hi,
its good idea to add unique class name for menu items, but the problem is that class name based on tag value. It's more logical to build it on the basis of href attribute value. Why? Because when we deal with a localized site (russian in my case), we have unique classes like this: -_-. Ciryllic (non-latin) symbols are filtered by function basic_id_safe().
So I suggest to replace this:
#New line added to get unique classes for each menu item
$css_class = basic_id_safe(str_replace(' ', '_', strip_tags($link)));
with this:
#New line added to get unique classes for each menu item
preg_match('/href=\"\/([^\"]+)\"/', $link, $matches);
$css_class = !empty($matches[1]) ? expert_id_safe(str_replace('/', '-', $matches[1])) : '';
see template.php, theme_menu_item implementation, line 363
I'm not skilled in making patches, sorry.
Comments
Comment #1
damiankloip commentedI'm not sure about how good it is to use a regular expression to theme menus that get rendered on every page...It'sa bit of an un necessary overhead. If you want to get around the whole translation thing it may be a better idea to use translation nids (tnids) on the body class instead?
Comment #2
damiankloip commented