Add Menu Classes In Drupal 7

Updated: 10 July, 2015 seen 2,301

In this Drupal tutorial I'll show how to add menu classes to your Drupal 7 website using template.php file.

Original of this tutorial has been found here.

Add this function to your template.php file:

* theme_menu_link()
function THEMENAME_menu_link(array $variables) {
//add class for li
   $variables['element']['#attributes']['class'][] = 'menu-' . $variables['element']['#original_link']['mlid'];
//add class for a
   $variables['element']['#localized_options']['attributes']['class'][] = 'menu-' . $variables['element']['#original_link']['mlid'];
  return theme_menu_link($variables);

P.S. If you are considering a hosting for your Drupal website check out Bluehost, their shared hosting starts as low as $3.95/mo or read more about cheap Drupal hosting.