简体   繁体   中英

Drupal 7 Customize Main Menu

I need following structure via Hook in the template.php (Drupal 7):

<ul class="first border">
<li><a href="#link"><span class="big">Main Menu Title</span><span class="small">Main Menu Description</span></a><ul class="flyout"><li class="submenu"><a href="#link">Submenu Item</a></li></ul></li></ul>

My current status in the template.php is following:

    function mytheme_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" && isset($element['#localized_options']['attributes']['title'])){
    $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";
}

I tried something but without success.

If you want to set classes on your menu options, download menu_attributes . To figure out why it's not working, did you change mytheme to your actual there name?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM