Am on my first foray into Drupal 7 theme development, and I'm attempting to override the Main Menu in order to print the item description underneath, using this code in template.php:
function MYTHEMENAME_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
$element['#localized_options']['html'] = TRUE;
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
if ($element['#original_link']['menu_name'] == "main-menu"){
$element['#title'] .= '<span class="description">'.$element['#localized_options']['attributes']['title'].'</span>';
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
and my main menu is printed out in the page.tpl.php as follows:
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'main-menu-links',
'class' => array('links', 'clearfix'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>