diff --git a/admin_menu.module b/admin_menu.module index 6fa85f2..cb1d9df 100644 --- a/admin_menu.module +++ b/admin_menu.module @@ -601,3 +601,43 @@ function admin_menu_form_devel_admin_settings_alter(&$form, &$form_state) { module_load_include('inc', 'admin_menu'); _admin_menu_form_devel_admin_settings_alter($form, $form_state); } + +/** + * Implementation of hook_admin_menu_output_alter(). + */ +function admin_menu_admin_menu_output_alter(&$content) { + // dpm($content, 'content'); + + // Find which menu item is "Content" - there must be a metter way? perhaps helper in http://drupal.org/node/821128 ? + foreach ($content['menu'] as $key => $item) { + if ($item['#href'] == 'admin/content') { + $content_key = $key; + break; + } + } + + // Re-add create content links. + if (isset($content_key)) { + // Ripped from sun's code at https://drupal.org/node/1025582 + $node_add = db_query("SELECT * FROM {menu_links} WHERE router_path = 'node/add' AND module = 'system'")->fetch(); + // dpm($node_add, 'node_add'); + $tree = menu_build_tree($node_add->menu_name, array( + 'conditions' => array('p1' => $node_add->mlid), + 'min_depth' => $node_add->depth, + )); + // dpm($tree, 'tree'); // For some reason, this returns two unwanted menu branches - with the wrong p1 conditions! WTF? + $tree = reset($tree); + $create_links = array( + '#title' => $tree['link']['link_title'], + '#href' => $tree['link']['link_path'], + ); + foreach ($tree['below'] as $branch) { + $create_links[$branch['link']['mlid']] = array( + '#title' => $branch['link']['link_title'], + '#href' => $branch['link']['link_path'], + ); + } + $content['menu'][$content_key][$tree['link']['mlid']] = $create_links; + } + // dpm($content, 'content'); +}