Index: menu_block.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/menu_block/menu_block.admin.inc,v retrieving revision 1.49 diff -u -p -r1.49 menu_block.admin.inc --- menu_block.admin.inc 26 Mar 2010 21:03:29 -0000 1.49 +++ menu_block.admin.inc 26 Mar 2010 21:59:52 -0000 @@ -142,8 +142,11 @@ function menu_block_add_block_form_submi * Alters the block admin form to add delete links next to menu blocks. */ function menu_block_form_block_admin_display_form_alter(&$form, $form_state) { + $blocks = module_invoke_all('menu_block_blocks'); foreach (variable_get('menu_block_ids', array()) AS $delta) { - $form['menu_block_' . $delta]['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => 'admin/structure/block/delete-menu-block/' . $delta); + if (!empty($blocks[$delta])) { + $form['menu_block_' . $delta]['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => 'admin/structure/block/delete-menu-block/' . $delta); + } } } @@ -196,7 +199,9 @@ function menu_block_delete_submit($form, */ function _menu_block_block_info() { $blocks = array(); - foreach (variable_get('menu_block_ids', array()) AS $delta) { + $deltas = variable_get('menu_block_ids', array()); + $deltas += array_keys(module_invoke_all('menu_block_blocks')); + foreach ($deltas AS $delta) { $blocks[$delta]['info'] = _menu_block_format_title(menu_block_get_config($delta)); // Menu blocks can't be cached because each menu item can have // a custom access callback. menu.inc manages its own caching. @@ -266,6 +271,9 @@ function _menu_block_format_title($confi function _menu_block_block_configure($delta = '') { // Create a pseudo form state. $form_state = array('values' => menu_block_get_config($delta)); + if (!empty($form_state['value']['exported_to_code'])) { + return array(); + } return menu_block_configure_form(array(), $form_state); } @@ -409,6 +417,7 @@ function menu_block_configure_form($form '#title' => t('Starting level will be'), '#default_value' => $follow_parent, '#options' => array( + 'parent' => t('Parent of active menu item'), 'active' => t('Active menu item'), 'child' => t('Children of active menu item'), ), Index: menu_block.api.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/menu_block/menu_block.api.php,v retrieving revision 1.2 diff -u -p -r1.2 menu_block.api.php --- menu_block.api.php 12 Mar 2010 17:30:00 -0000 1.2 +++ menu_block.api.php 26 Mar 2010 21:59:52 -0000 @@ -23,6 +23,41 @@ function hook_menu_block_tree_alter(&$tr } /** + * Return a list of configurations for menu blocks. + * + * Modules that want to have menu block configurations exported to code should + * provide them using this hook. + * + * @see menu_tree_build() for a description of the config array. + */ +function hook_menu_block_blocks() { + return array( + // The array key is the block id used by menu block. + 'custom-nav' => array( + // Use the array keys/values described in menu_tree_build(). + 'menu_name' => 'primary-links', + 'parent_mlid' => 0, + 'title_link' => FALSE, + 'admin_title' => 'Drop-down navigation', + 'level' => 1, + 'follow' => 0, + 'depth' => 2, + 'expanded' => TRUE, + 'sort' => FALSE, + ), + // To prevent clobbering of the block id, it is recommended to prefix it + // with the module name. + 'custom-active' => array( + 'menu_name' => MENU_TREE__CURRENT_PAGE_MENU, + 'title_link' => TRUE, + 'admin_title' => 'Secondary navigation', + 'level' => 3, + 'depth' => 3, + // Any config options not specified will get the default value. + ); +} + +/** * Return a list of menus to use with the menu_block module. * * @return Index: menu_block.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/menu_block/menu_block.module,v retrieving revision 1.76 diff -u -p -r1.76 menu_block.module --- menu_block.module 26 Mar 2010 21:03:29 -0000 1.76 +++ menu_block.module 26 Mar 2010 21:59:52 -0000 @@ -135,6 +135,19 @@ function menu_block_get_config($delta = // Get the block configuration options. if ($delta) { + static $blocks; + if (!isset($blocks)) { + $blocks = module_invoke_all('menu_block_blocks'); + } + if (!empty($blocks[$delta])) { + // Merge the default values. + $config = $blocks[$delta] + $config; + // Set the delta. + $config['delta'] = $delta; + // Flag the block as exported. + $config['exported_to_code'] = TRUE; + } + $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']);