diff --git menu_block.admin.inc menu_block.admin.inc index 8b8d849..d42d0b9 100644 --- menu_block.admin.inc +++ menu_block.admin.inc @@ -269,7 +269,7 @@ function menu_block_configure_form(&$form_state) { '#type' => 'select', '#title' => t('Starting level'), '#default_value' => $config['level'], - '#options' => array( + '#options' => array( '1' => t('1st level (primary)'), '2' => t('2nd level (secondary)'), '3' => t('3rd level (tertiary)'), @@ -282,6 +282,13 @@ function menu_block_configure_form(&$form_state) { ), '#description' => t('Blocks that start with the 1st level will always be visible. Blocks that start with the 2nd level or deeper will only be visible when the trail to the active menu item is in the block’s tree.'), ); + + $form['include_parent'] = array( + '#type' => 'checkbox', + '#title' => t('Include Parent'), + '#default_value' => $config['include_parent'], + '#description' => t('Should this block include the parent as the starting level?'), + ); // The value of "follow" in the database/config array is either FALSE or the // value of the "follow_parent" form element. if ($follow = $config['follow']) { @@ -372,6 +379,7 @@ function _menu_block_block_save($delta, $edit) { variable_set("menu_block_{$delta}_title_link", $edit['title_link']); variable_set("menu_block_{$delta}_admin_title", $edit['admin_title']); variable_set("menu_block_{$delta}_parent", $edit['parent']); + variable_set("menu_block_{$delta}_include_parent", $edit['include_parent']); variable_set("menu_block_{$delta}_level", $edit['level']); variable_set("menu_block_{$delta}_follow", $edit['follow']); variable_set("menu_block_{$delta}_depth", $edit['depth']); diff --git menu_block.module menu_block.module index fb535da..fd3251e 100644 --- menu_block.module +++ menu_block.module @@ -175,6 +175,7 @@ function menu_block_get_config($delta = NULL) { 'parent_mlid' => 0, 'title_link' => 0, 'admin_title' => '', + 'include_parent' => 0, 'level' => 1, 'follow' => 0, 'depth' => 0, @@ -184,13 +185,14 @@ function menu_block_get_config($delta = NULL) { // Get the block configuration options. if ($delta) { - $config['title_link'] = variable_get("menu_block_{$delta}_title_link", $config['title_link']); - $config['admin_title'] = variable_get("menu_block_{$delta}_admin_title", $config['admin_title']); - $config['level'] = variable_get("menu_block_{$delta}_level", $config['level']); - $config['follow'] = variable_get("menu_block_{$delta}_follow", $config['follow']); - $config['depth'] = variable_get("menu_block_{$delta}_depth", $config['depth']); - $config['expanded'] = variable_get("menu_block_{$delta}_expanded", $config['expanded']); - $config['sort'] = variable_get("menu_block_{$delta}_sort", $config['sort']); + $config['title_link'] = variable_get("menu_block_{$delta}_title_link", $config['title_link']); + $config['admin_title'] = variable_get("menu_block_{$delta}_admin_title", $config['admin_title']); + $config['level'] = variable_get("menu_block_{$delta}_level", $config['level']); + $config['follow'] = variable_get("menu_block_{$delta}_follow", $config['follow']); + $config['depth'] = variable_get("menu_block_{$delta}_depth", $config['depth']); + $config['expanded'] = variable_get("menu_block_{$delta}_expanded", $config['expanded']); + $config['sort'] = variable_get("menu_block_{$delta}_sort", $config['sort']); + $config['include_parent'] = variable_get("menu_block_{$delta}_include_parent", $config['include_parent']); list($config['menu_name'], $config['parent_mlid']) = explode(':', variable_get("menu_block_{$delta}_parent", $config['menu_name'] . ':' . $config['parent_mlid'])); } @@ -289,7 +291,7 @@ function menu_tree_build($config) { if ($config['level'] > 1 || $config['parent_mlid']) { if ($config['parent_mlid']) { $parent_item = menu_link_load($config['parent_mlid']); - menu_tree_prune_tree($tree, $config['level'], $parent_item); + menu_tree_prune_tree($tree, $config['level'], $parent_item, $config['include_parent']); } else { menu_tree_prune_tree($tree, $config['level']); @@ -477,7 +479,7 @@ function menu_tree_sort_active_path(&$tree) { * @return * void */ -function menu_tree_prune_tree(&$tree, $level, $parent_item = FALSE) { +function menu_tree_prune_tree(&$tree, $level, $parent_item = FALSE, $include_parent = FALSE) { if (!empty($parent_item)) { // Prune the tree along the path to the menu item. for ($i = 1; $i <= MENU_MAX_DEPTH && $parent_item["p$i"] != '0'; $i++) { @@ -488,8 +490,12 @@ function menu_tree_prune_tree(&$tree, $level, $parent_item = FALSE) { if ($tree[$key]['link']['mlid'] == $plid) { menu_block_set_title($tree[$key]['link']); // Prune the tree to the children of this ancestor. - $tree = $tree[$key]['below'] ? $tree[$key]['below'] : array(); $found_active_trail = TRUE; + if($include_parent) { + $tree = array($key=>$tree[$key]); + } else { + $tree = $tree[$key]['below'] ? $tree[$key]['below'] : array(); + } break; } }