Add Menu Classes In Drupal 7

| Drupal Development | 45 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.

 

Latest articles

Investing in Ireland: Exploring the Irish Stock Market and Top Dividend Stocks

Ireland is not usually the first country that comes to mind when thinking about European stock markets. Most investors looking at Europe tend to focus on larger markets such as Germany, France, or the Netherlands. Yet Ireland has a surprisingly long stock market history and is home to several internationally known companies.As we are planning a…

Investing |

Why I Sold Put Options on Lufthansa Stock (LHA) – Earning 14.5% Annualized Yield

Recently, after booking a trip to Ireland with Lufthansa, I found myself taking a closer look at the company's stock.As I commented on LinkedIn:"Another interesting European stock to play with is Lufthansa (LHA). After booking a trip to Ireland with them, I decided to sell some short put options on the stock. As long as it doesn't go belly up,…

Options trading |