You are here

function theme_mmenu_tree in Mobile sliding menu 7

Same name and namespace in other branches
  1. 8 mmenu.module \theme_mmenu_tree()
  2. 7.3 mmenu.module \theme_mmenu_tree()
  3. 7.2 mmenu.module \theme_mmenu_tree()

Returns HTML for a wrapper for a mmenu tree.

Parameters

array $block: An associative array containing:

  • tree: An array containing the tree's items.
  • reset: An boolean to determine if needs to reset the static variable.
1 theme call to theme_mmenu_tree()
template_preprocess_mmenu in ./mmenu.module
Processes variables for mmenu.tpl.php.

File

./mmenu.module, line 926
Primarily Drupal hooks and global API functions to manipulate mmenus.

Code

function theme_mmenu_tree($block = array(
  'tree' => array(),
  'reset' => FALSE,
)) {
  $tree = $block['tree'];
  $reset = $block['reset'];

  // Don't render if block content is empty.
  if (count($tree) <= 0) {
    return '';
  }
  static $mmenu_output = '';
  if ($reset) {
    $mmenu_output = '';
  }
  foreach ($tree as $item) {
    $cur_path = url($_GET['q']);
    $menu_path = url($item['link']['link_path']);
    $icon_menu_path = $menu_path;
    if ($icon_menu_path == '/') {
      $icon_menu_path = 'home';
    }
    $class = $cur_path == $menu_path ? 'active-trail' : '';
    $icon_class = ' ' . 'mmenu-list-icon-' . str_replace('/', '-', trim($icon_menu_path, '/')) . ' ';
    $mmenu_output .= '<li class="' . $class . '"><a href="' . $menu_path . '" class="mmenu-list"><i class="mmenu-list-icon ' . $icon_class . '"></i><span class="mmenu-list-title">' . $item['link']['link_title'] . '</span></a>';
    if (isset($item['below']) && count($item['below']) > 0) {
      $mmenu_output .= '<ul>';
      theme('mmenu_tree', array(
        'tree' => $item['below'],
        'reset' => FALSE,
      ));
      $mmenu_output .= '</ul>';
    }
    $mmenu_output .= '</li>';
  }
  return '<ul>' . $mmenu_output . '</ul>';
}