Commit 10e01f42 authored by stefan.r's avatar stefan.r Committed by Dave Reid

Issue #2283897 by stefan.r, mdeltito: Fixed "starting level follow active menu...

Issue #2283897 by stefan.r, mdeltito: Fixed "starting level follow active menu item" option to work with the "maximum depth" option.
parent 80d82dde
......@@ -360,6 +360,17 @@ function menu_block_configure_form($form, &$form_state) {
),
'#description' => t('From the starting level, specify the maximum depth of the menu tree.'),
);
$form['depth_relative'] = array(
'#type' => 'checkbox',
'#title' => t('Make the maximum depth relative to the starting level while following the active menu item.'),
'#default_value' => $config['depth_relative'],
'#states' => array(
'visible' => array(
':input[name=follow]' => array('checked' => TRUE),
':input[name=depth]' => array('!value' => '0'),
),
),
);
$form['expanded'] = array(
'#type' => 'checkbox',
'#title' => t('<strong>Expand all children</strong> of this tree.'),
......@@ -384,7 +395,7 @@ function menu_block_configure_form($form, &$form_state) {
$form['menu-block-wrapper-close'] = array('#markup' => '</div>');
// Set visibility of advanced options.
foreach (array('title_link', 'follow', 'follow_parent', 'expanded', 'sort', 'parent') as $key) {
foreach (array('title_link', 'follow', 'depth_relative', 'follow_parent', 'expanded', 'sort', 'parent') as $key) {
$form[$key]['#states']['visible'][':input[name=display_options]'] = array('value' => 'advanced');
}
if ($config['title_link'] || $follow || $config['expanded'] || $config['sort'] || $config['parent_mlid']) {
......@@ -433,6 +444,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}_depth_relative", $edit['depth_relative']);
variable_set("menu_block_{$delta}_expanded", $edit['expanded']);
variable_set("menu_block_{$delta}_sort", $edit['sort']);
}
......
......@@ -242,6 +242,7 @@ function menu_block_default_config() {
'level' => 1,
'follow' => 0,
'depth' => 0,
'depth_relative' => 0,
'expanded' => 0,
'sort' => 0,
);
......@@ -346,7 +347,7 @@ function menu_tree_block_data(array &$config) {
if ($config['expanded'] || $config['parent_mlid']) {
// Get the full, un-pruned tree.
if ($config['parent_mlid']) {
if ($config['parent_mlid'] || $config['depth_relative']) {
$tree = menu_tree_all_data($config['menu_name']);
}
else {
......@@ -356,8 +357,13 @@ function menu_tree_block_data(array &$config) {
menu_tree_add_active_path($tree);
}
else {
// Get the tree pruned for just the active trail.
$tree = menu_tree_page_data($config['menu_name'], $max_depth);
if ($config['depth_relative']) {
// Get the tree pruned for just the active trail.
$tree = menu_tree_page_data($config['menu_name']);
}
else {
$tree = menu_tree_page_data($config['menu_name'], $max_depth);
}
}
// Allow alteration of the tree and config before we begin operations on it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment