3

I need to add a span tag before mt

if i add like

function mytheme_link($variables) {
  return '<span><a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a></span>';
}

it will add for all the menus

and if i use

function mytheme_menu_link($link) {
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }

  $link['localized_options']['html'] = TRUE; //let l function know that our link title includes html
  return '<span>'.l($link['title'], $link['href'], $link['localized_options']).'</span>';
}

it does not add at all.

2
  • have you cleared all caches? take also a look at the theme_menu_link Commented Nov 25, 2011 at 12:39
  • @anonym-developer - added it and cleared cache also.no use.
    – Hacker
    Commented Nov 25, 2011 at 12:45

1 Answer 1

3

you have forgotten the '#' before localized_options, title & href.

function mytheme_menu_link($link) {
  if (empty($link['#localized_options'])) {
    $link['#localized_options'] = array();
  }

  $link['#localized_options']['html'] = TRUE; //let l function know that our link title includes html
  return '<span>'.l($link['#title'], $link['#href'], $link['#localized_options']).'</span>';
}

for main menue only use theme_menu_link__main_menu($var)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.