diff --git a/core/modules/toolbar/config/toolbar.settings.yml b/core/modules/toolbar/config/toolbar.settings.yml new file mode 100644 index 0000000..d0047f7 --- /dev/null +++ b/core/modules/toolbar/config/toolbar.settings.yml @@ -0,0 +1 @@ +depth: 9 diff --git a/core/modules/toolbar/toolbar.admin.inc b/core/modules/toolbar/toolbar.admin.inc new file mode 100644 index 0000000..8f836a1 --- /dev/null +++ b/core/modules/toolbar/toolbar.admin.inc @@ -0,0 +1,30 @@ + 'select', + '#title' => t('Menu depth to display'), + '#default_value' => $config->get('depth'), + '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9)), + '#required' => TRUE, + ); + return system_config_form($form, $form_state); +} + +/** + * Form submission handler for toolbar_admin_settings(). + */ +function toolbar_admin_settings_submit($form, &$form_state) { + config('toolbar.settings') + ->set('depth', $form_state['values']['depth']) + ->save(); +} diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index f60a817..d0727d3 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -45,6 +45,21 @@ function toolbar_theme($existing, $type, $theme, $path) { } /** + * Implements hook_menu(). + */ +function toolbar_menu() { + $items['admin/config/user-interface/toolbar'] = array( + 'title' => 'Administrative navigation', + 'description' => 'Configure toolbar settings', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('toolbar_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'file' => 'toolbar.admin.inc', + ); + return $items; +} + +/** * Implements hook_page_build(). * * Add admin toolbar to the page_bottom region automatically. @@ -222,7 +237,10 @@ function toolbar_get_menu_tree() { $tree = array(); $admin_link = db_query('SELECT * FROM {menu_links} WHERE menu_name = :menu_name AND module = :module AND link_path = :path', array(':menu_name' => 'management', ':module' => 'system', ':path' => 'admin'))->fetchAssoc(); if ($admin_link) { - $tree = menu_tree_all_data('management'); + // Add 1 to the depth to take into account the root "Administration" item in + // the Management menu. + $max_depth = config('toolbar.settings')->get('depth') + 1; + $tree = menu_tree_all_data('management', NULL, $max_depth); } // Return the sub-menus of the management menu root. foreach ($tree as $key => $menu) {