diff --git a/menu_block.admin.inc b/menu_block.admin.inc index 992a0cc..2236d1a 100644 --- a/menu_block.admin.inc +++ b/menu_block.admin.inc @@ -164,6 +164,7 @@ function menu_block_delete_submit($form, &$form_state) { variable_del("menu_block_{$delta}_level"); variable_del("menu_block_{$delta}_follow"); variable_del("menu_block_{$delta}_depth"); + variable_del("menu_block_{$delta}_relative"); variable_del("menu_block_{$delta}_expanded"); variable_del("menu_block_{$delta}_sort"); @@ -412,6 +413,11 @@ function menu_block_configure_form($form, &$form_state) { ), '#description' => t('From the starting level, specify the maximum depth of the menu tree.'), ); + $form['relative'] = array( + '#type' => 'checkbox', + '#title' => t('Allow depth to be relative to the starting level when following the active menu item.'), + '#default_value' => $config['relative'], + ); $form['expanded'] = array( '#type' => 'checkbox', '#title' => t('Expand all children of this tree.'), @@ -485,6 +491,7 @@ function _menu_block_block_save($delta = '', $edit = array()) { variable_set("menu_block_{$delta}_level", $edit['level']); variable_set("menu_block_{$delta}_follow", $edit['follow']); variable_set("menu_block_{$delta}_depth", $edit['depth']); + variable_set("menu_block_{$delta}_relative", $edit['relative']); variable_set("menu_block_{$delta}_expanded", $edit['expanded']); variable_set("menu_block_{$delta}_sort", $edit['sort']); } diff --git a/menu_block.module b/menu_block.module index f27659b..51e116b 100644 --- a/menu_block.module +++ b/menu_block.module @@ -215,6 +215,7 @@ function menu_block_get_config($delta = NULL) { 'level' => 1, 'follow' => 0, 'depth' => 0, + 'relative' => 0, 'expanded' => 0, 'sort' => 0, ); @@ -239,6 +240,7 @@ function menu_block_get_config($delta = NULL) { $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['relative'] = variable_get("menu_block_{$delta}_relative", $config['depth']); $config['expanded'] = variable_get("menu_block_{$delta}_expanded", $config['expanded']); $config['sort'] = variable_get("menu_block_{$delta}_sort", $config['sort']); $config['parent'] = variable_get("menu_block_{$delta}_parent", $config['menu_name'] . ':' . $config['parent_mlid']); @@ -260,7 +262,7 @@ function menu_tree_block_data(&$config) { if ($config['expanded'] || $config['parent_mlid']) { // Get the full, un-pruned tree. - if ($config['parent_mlid']) { + if ($config['parent_mlid'] || $config['relative']) { $tree = menu_tree_all_data($config['menu_name']); } else {