Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Greetings,
The menu tree classes and ID defined in menu.inc menu_tree are applied to every menu which is bad because the main menu usually has some special css and effects that for example are not desirable in a custom footer or sidebar menu. Can menu.inc be updated to ONLY apply to main menu? Can you help me rewrite this snippet:
function webmarket_menu_tree(&$variables){
return '<ul class="my class">' . $variables['tree'] . '</ul>';
}
So that it applies to ONLY the main menu and not all other menus on the site? Many thanks! Kevin
Comments
Comment #1
shadcn CreditAttribution: shadcn commentedYep. In template.php, you can add this code snippet inside the template_preprocess_page implementation.
then in menu.inc add this function:
Flush cache.
Comment #2
pyxio CreditAttribution: pyxio commentedawesome. thanks for this! cheers Kevin
Comment #3
pyxio CreditAttribution: pyxio commentedHi
I just had a chance to test this. Unfortunately... this does not work. all menus remain the same with the same markup as default drupal main menu. I know this has something to do with D7 problematic menu structures. I am wondering if better is to totally remove menu.inc from the theme but then i am not sure how to deal with menus. The fact is, other menus on site in sidebars and footer cannot inherit same styles as main menu. So this is a dilemma. Probably your approach is good but maybe the code has a bug somewhere. I definitely appreciate all of your help over the months and the great theme. Thanks Kevin
Comment #4
shadcn CreditAttribution: shadcn commentedOpen Atrium is overwriting this by calling theme_menu_tree. See the implementation here: http://drupalcode.org/project/oa_radix.git/blob/refs/heads/7.x-2.x:/incl...
Closing this issue. Feel free to re-open.
Thanks