You are here

function theme_menu_icons_build in Menu Icons 6

Helper function that builds the nested lists of a nice menu. Borrowed from nice_menus

Parameters

$menu: Menu array from which to build the nested lists.

1 theme call to theme_menu_icons_build()
theme_menu_icons_tree in ./menu_icons.module
Theme a given menu tree, with icons

File

./menu_icons.module, line 227
Module to associate icons with menu items

Code

function theme_menu_icons_build($menu, $hide_children = FALSE, $hide_titles = FALSE) {

  // TODO - enable supression of link titles to show icons only
  $output = '';
  foreach ($menu as $menu_item) {
    $mlid = $menu_item['link']['mlid'];

    // Check to see if it is a visible menu item.
    if ($menu_item['link']['hidden'] == 0) {

      // Build class name based on menu path
      // e.g. to give each menu item individual style.
      // Strip funny symbols.
      $clean_path = str_replace(array(
        'http://',
        '<',
        '>',
        '&',
        '=',
        '?',
        ':',
      ), '', $menu_item['link']['href']);

      // Convert slashes to dashes.
      $clean_path = str_replace('/', '-', $clean_path);
      $path_class = 'menu-path-' . $clean_path;

      // If it has children build a nice little tree under it.
      if (!empty($menu_item['link']['has_children']) && !empty($menu_item['below']) && !$hide_children) {

        // Keep passing children into the function 'til we get them all.
        $children = theme('menu_icons_build', $menu_item['below']);

        // Set the class to parent only of children are displayed.
        $parent_class = $children ? 'menuparent ' : '';
        $output .= '<li id="menu-' . $mlid . '" class="' . $parent_class . $path_class . '">' . theme('menu_item_link', $menu_item['link']);

        // Build the child UL only if children are displayed for the user.
        if ($children) {
          $output .= '<ul>';
          $output .= $children;
          $output .= "</ul>\n";
        }
        $output .= "</li>\n";
      }
      else {
        $output .= '<li id="menu-' . $mlid . '" class="' . $path_class . '">' . theme('menu_item_link', $menu_item['link']) . '</li>' . "\n";
      }
    }
  }
  return $output;
}