Drupal Override Custom Menu Template

前端 未结 4 1815
挽巷
挽巷 2020-12-08 16:23

I created a custom menu called \"sub-top-nav\" and now I\'d like to override the html output. In particular I would like to add an unique class to each item like.

Th

4条回答
  •  无人及你
    2020-12-08 16:47

    I got it to work now. This piece of code might help someone else as well! It goes into yourtheme/template.php

    function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
    
      $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
    
      if (!empty($extra_class))
        $class .= ' '. $extra_class;
    
      if ($in_active_trail)
        $class .= ' active-trail';
    
      $class .= ' ' . preg_replace('/[^a-zA-Z0-9]/', '', strtolower(strip_tags($link)));
    
      return '
  • '. $link . $menu ."
  • \n"; }

提交回复
热议问题