aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--finder_menu.module56
1 files changed, 55 insertions, 1 deletions
diff --git a/finder_menu.module b/finder_menu.module
index 1b65d7e..9341aad 100644
--- a/finder_menu.module
+++ b/finder_menu.module
@@ -129,7 +129,7 @@ function theme_finder_menu($menu_name, $mlid) {
// Build the menus
$output = '<div id="finderparent">';
- $output .= taxonomy_node_tree_list($menu, 'finder', 'hidden');
+ $output .= finder_menu_list($menu, 'finder', 'hidden');
$output .= '</div>';
return $output;
@@ -152,3 +152,57 @@ function theme_finder_menu_javascript() {
function theme_finder_menu_css() {
drupal_add_css(drupal_get_path('module', 'finder_menu') .'/finder_menu.css');
}
+
+/**
+ * Recursively build the menu.
+ *
+ * @ingroup themeable
+ */
+function finder_menu_list($menu, $id, $class, &$level = NULL) {
+
+ if ($level == NULL) {
+ $output = '<ul id="' . $id .'" class="'. $class .'">';
+ $output .= implode((array) module_invoke_all('finder_menu_list'));
+ $level = 0;
+ }
+ else {
+ $output = '<ul id="'. $id .'[ul]['. $level .']" class="'. $class .'">';
+ }
+
+ foreach ($menu as $menu_item) {
+ if ($menu_item['link']['hidden'] == 0) {
+ $output .= '<li>';
+ if ($menu_item['below'] !== FALSE && finder_menu_has_unhidden_submenu($menu_item['below'])) {
+ $level++;
+ $output .= $menu_item['link']['title'];
+ $output .= finder_menu_list($menu_item['below'], $id, $class, $level);
+ }
+ else {
+ $output .= theme('menu_item_link', $menu_item['link']);
+ }
+ $output .= '</li>';
+ }
+ }
+
+ $output .= '</ul>';
+ return $output;
+
+}
+
+/**
+ * Check whether a menu has at least one unhidden submenu.
+ */
+function finder_menu_has_unhidden_submenu($menu = FALSE) {
+
+ if ($menu == FALSE) {
+ return FALSE;
+ }
+
+ foreach ($menu as $menu_item) {
+ if ($menu_item['link']['hidden'] == 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}