I have a problem theming the links of main menu. I was using Fusion and i added span tags to main menu tags with this function.

function yourtheme_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }

  $element['#localized_options']['html'] = TRUE;
  $linktext = '<span class="your_class">' . $element['#title'] . '</span>';

  $output = l($linktext, $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}

Now i am trying to use it with omega and doesnt do nothing. I put the function at the template.php file and cashe but nothing at all.
Am i missing something about omega theme?
Does anybody no how i can do it
Thank yoy very much.

Comments

damiandab’s picture

the same problem :(

apmsooner’s picture

This code here will add the span tag... perhaps you can build on it:

<?php
function YOURTHEME_links__system_main_menu(&$vars) {
  foreach ($vars['links'] as &$link) {
    $link['title'] = '<span>' . $link['title'] . '</span>';
    $link['html'] = TRUE;
  }
  return theme_links($vars);
}
?>
apmsooner’s picture

Actually in doing some research, that function in the original post works just fine if you're using the menu as a block. If you have it set in the theme settings however to render on page, its a different function so... simple solution is just disable the theme menu and use the block and you're good to go :)

...and you may just want to target the main menu block in which case you would specify it in the code like so:

<?php
function yourtheme_menu_link__main_menu(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }

  $element['#localized_options']['html'] = TRUE;
  $linktext = '<span class="your_class">' . $element['#title'] . '</span>';

  $output = l($linktext, $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
?>
fubhy’s picture

Status: Active » Fixed

Glad that you worked it out yourself.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.