Add Menu Classes In Drupal 7

| Drupal Development | 8 seen

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:

<?php
/**
* 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'];
//dvm($variables['element']);
  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.

Add new comment