0
votes

I need to put styles in a Drupal Menu. I have this code:

print theme('links', array('links' => menu_navigation_links($menu_area), 'attributes' => array('class'=> array('nav', 'navbar-nav')) ));

The < ul > have the "nav navbar-nav" style but the < li > have a custom CSS style (menu-7053 first) that I can't touch.

Is there any way to change that < li > style with the print theme function?

Thank you.

2

2 Answers

0
votes

No you can't, you need to implement your own theme_menu_link function in your theme.

function YOURTHEME_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  $element['#attributes']['class'][] = 'my-custom-li-class'; // change here to desired css class name

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }

  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
0
votes

You can use Menu attributes(https://www.drupal.org/project/menu_attributes) module & add class to li by editing menu item from backend. Please check screenshot below:

enter image description here