logo

Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Menu theming (template.php)

29/07/2025, by Ivan
Forums

Hello, I insert the following code into the template.php file:

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

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

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

But the <span> tag does not appear.

function your_theme_name_links__system_main_menu(&$vars) {
  foreach ($vars['links'] as &$link) {
    $link['title'] = '<span>' . $link['title'] . '</span>';
    $link['html'] = TRUE;
  }
  return theme_links($vars);
}

This construction works, but the wrapper is not where it should be — inside the <a><span></span></a> tag.

Please tell me what is the reason the first construction does not work?