default.php 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Default menu
  4. *
  5. * @uses $vars['name'] Name of the menu
  6. * @uses $vars['menu'] Array of menu items
  7. * @uses $vars['class'] Additional CSS class for the menu
  8. * @uses $vars['item_class'] Additional CSS class for each menu item
  9. * @uses $vars['show_section_headers'] Do we show headers for each section?
  10. */
  11. // we want css classes to use dashes
  12. $vars['name'] = preg_replace('/[^a-z0-9\-]/i', '-', $vars['name']);
  13. $headers = elgg_extract('show_section_headers', $vars, false);
  14. $item_class = elgg_extract('item_class', $vars, '');
  15. $class = "elgg-menu elgg-menu-{$vars['name']}";
  16. if (isset($vars['class'])) {
  17. $class .= " {$vars['class']}";
  18. }
  19. foreach ($vars['menu'] as $section => $menu_items) {
  20. echo elgg_view('navigation/menu/elements/section', array(
  21. 'items' => $menu_items,
  22. 'class' => "$class elgg-menu-{$vars['name']}-$section",
  23. 'section' => $section,
  24. 'name' => $vars['name'],
  25. 'show_section_headers' => $headers,
  26. 'item_class' => $item_class,
  27. ));
  28. }