You are here

Customizing the primary menu links in Drupal 7

In some cases, we might to add some extra class or some extra attributes to the primary menu link in Drupal 7.

There are different ways of doing it. I have used the template.php file to customize the links. A template.php files resides inside your themes folder. Add this function to your template file and customize the links

function themename_links__system_main_menu($variables) {
$html = " <ul class='main-menu'>";
foreach ($variables['links'] as $k => $link) {
$html .= "<li>".l($link['title'], $link['href'], array('attributes' => array('class' => 'reflect '.$k.'')))."</li>";
}
$html .= " </ul>";
return $html;
}
Note : Remember to change the name of the function, themename will be replaced by your themename.

Website fix request form

If you have problems with the website based on Drupal or WordPress, please feel free to contact us: