简体   繁体   中英

Drupal 7: Modifying menu title

I would like to know how I can modify the menu title within the template.php of the theme I am using.

So far, I have been able to modify both the UL and LI elements by using hooks: THEME-NAME_menu_tree__MENU-NAME and THEME-NAME_menu_link__MENU-NAME respectively. However, I cannot access the menu title form either of those (or at least that's what I think). I have tried to use the THEME-NAME_menu__MENU-NAME hook, but it seems that the function is simply being ignored.

Thank you for your time.

Your menu is generated within a block. You should be able to change the subject / title by preprocessing the block. For example, change all subjects of blocks and wrap a <span> around it.

function MYTHEME_preprocess_block(&$variables) {
  $block = $variables['block'];
  $block->subject = sprintf('<span>%s</span>', $block->subject);
}

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